In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Preface
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types, including string (string), list (linked list), set (collection), zset (sorted set-ordered collection), and hash (hash type). These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic.
To install Redis, you need to know which version you need and a targeted installation. For example, if you need the feature of redis GEO as a geographic collection, then the redis version cannot be lower than version 3.2, because this feature is only available in version 3.2.
It should also be noted that Redis stipulates that the version with an even version number (that is, the number after the first decimal point) is stable (such as 2.8,3.0), and the odd version is unstable (such as 2.7,2.9). A stable version is generally required in production environment. 、
Download the installation package
Wget http://download.redis.io/releases/redis-4.0.2.tar.gz
Extract the installation package and install
Tar xzf redis-4.0.2.tar.gzcd redis-4.0.2makemake install
Redis has no other external dependencies, and the installation process is simple. After compilation, you can find several executables in the src folder of the Redis source directory, and after installation, you can find the redis executable you just installed in the / usr/local/bin directory.
As shown below:
Start and stop Redis
Start Redis
Direct start
Run redis-server directly to start Redis
[root@localhost bin] # redis-server
Start Redis through the initialization script
There is an initialization script file called redis_init_script in the utils folder of the Redis source directory. You need to configure the operation of Redis and the storage location of persistence files and log files. The steps are as follows:
1. Configure initialization script
First copy the initialization script to the / etc/init.d directory, and the file name is the redis_ port number, where the port number represents the port number that you want Redis to listen on, and the client connects to Redis through this port. Then change the value of the REDISPORT variable on line 6 of the script to the same port number.
2. Create the following required folders.
3. Modify the configuration file
First copy the configuration file template (redis-4.0.2/redis.conf) to the / etc/redis directory, name it with the port number (such as "6379.conf"), and then edit some of the parameters according to the following table.
Now you can also use the following command to start and shut down Redis
/ etc/init.d/redis_6379 start/etc/init.d/redis_6379 stop
[top priority] Let Redis start automatically with the system. You also need to make simple changes to the Redis initialization script and execute the command:
Vim / etc/init.d/redis_6379
In the fourth line of the header of the open redis initialization script file, append the following two sentences
# chkconfig: 2345 90 10 # description: Redis is a persistent key-value database
The effect of the addition is as follows:
In the red box above, there are two additional lines of comments. After you have added them, you can save them and add Redis to the system startup item with the following command.
/ / set to boot and execute redis script chkconfig redis_6379 on
After doing the above, you can also start and shut down Redis directly with the following command, as follows
Service redis_6379 startservice redis_6379 stop
After the above deployment operation, the system restarts, and Redis starts automatically with the system, and Redis persistence is also configured in the above steps. The next time you start the system or Redis, the cache data will not be lost.
Stop Redis
Given that Redis may be synchronizing data in memory to the hard disk, forcibly terminating the Redis process may result in data loss. The correct way to stop Redis should be to send a SHUTDOWN command to Redis by:
Redis-cli SHUTDOWN
When Redis receives the SHUTDOWN command, it first disconnects all client connections, then persists according to the configuration, and finally completes the exit.
Redis can handle SIGTERM signals properly, so using the PID of the kill Redis process can also end the Redis normally, just like sending the SHUTDOWN command.
The above are the details of the installation method of Redis under CentOS, please pay attention to other related articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.