Redis official website download address: https://redis.io/download, latest version: 4.0.8, as shown below:
The installation steps are as follows:
--1. Download wget http://download.redis.io/releases/redis-4.0.8.tar.gz (If you are a command-line version of CentOS, you need to install the C language environment using the following command.) yum install gcc-c++ )
--2. Unzip the installation package and install it (directory/root/pack/redis-4.0.8) tar -xf redis-4.0.8.tar.gz cd redis-4.0.8 make make install
--3. Create a redis configuration folder and storage folder mkdir -p /etc/redis mkdir -p /var/redis/6379
--4. Copy the configuration file cp /root/pack/redis-4.0.8/redis.conf /etc/redis/6379.conf
--5. Modify the 6379.conf configuration file daemonize to yes dir repair car completion/var/redis/6379 Comment out bind 127.0.0.1 Open RequirePass and set the password to xxxxxx
--6. Copy the startup script file cp /root/pack/redis-4.0.8/utils/redis_init_script /etc/init.d/redis_6379
--7. You can now use the following commands to start and close Redis
/etc/init.d/redis_6379 start
/etc/init.d/redis_6379 stop
--8. After setting the password, use /etc/init.d/redis_6379 stop to solve the invalid solution stop) item to add the password -a xxxxxx
--9. Let Redis start automatically with the system This also requires a simple modification of the Redis initialization script, adding the following two sentences to the position of the fourth line at the head of the opened redis initialization script file: # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database
In the red box in the picture above, there are two additional lines of comments, and after adding, save it, and you can add Redis to the system startup item through the following command
--10. Set the boot to execute the redis script chkconfig redis_6379 on
--After passing the above operations, you can also directly use the following commands to start and close Redis in the future, as follows
Stop Redis
Considering that Redis may be syncing data in memory to the hard drive, forcibly killing the Redis process can result in data loss. The correct way to stop Redis should be to send a SHUTDOWN command to Redis, which is:
redis-cli SHUTDOWN When Redis receives the SHUTDOWN command, it will first disconnect all clients, then perform persistence according to the configuration, and finally complete the exit. Redis can handle SIGTERM signals properly, so PIDs using the kill Redis process can also terminate Redis normally, just like sending a SHUTDOWN command.
Finally, attach the 6379.conf and redis_6379 configuration file:
The 6379.conf file is as follows:
redis_6379 profile:
|