It is also recently (there are a lot of things installed in the environment recently). Although the process of installing the redis service under Linux is relatively smooth, after thinking about it, I think it is better to record it.
Let’s briefly introduce the standard solution for installing redis service. There should be at least 3 cloud hosts, one of which is used to run only Sentinel sentinel service, and the remaining two run both Redis service and Sentinel service on Redis service. , but there is a master-slave distinction. They implement Redis cluster and implement data synchronization themselves.
However, at present, due to limited conditions, there are only two machines available for me to use, so I don't have a cloud host dedicated to running Sentinel Sentinel service on the left in the above picture, but it has little impact in the development and test environment. Next, I will introduce my installation, configuration, start and stop process in detail.
1. Check whether the following two softwares have been installed on the machine
rpm -qa | grep tcl
2. View and create new redis users and groups
cat /etc/passwd # View users cat /etc/group # View group groupadd redis # create a new group useradd redis -g redis # Create a new user and add it to the group
3. Upload the installation to the installation directory, here is /home/redis/, the following commands are executed using the redis user
cd /home/redis/ tar -xvf redis-2.6.17.tar.gz cd redis-2.6.17 make test make PREFIX=/home/redis install
4. Copy the configuration file of the installation directory to /etc/
cp /home/redis/redis-2.6.17/redis.conf /etc/ cp /home/redis/redis-2.6.17/sentinel.conf /etc/
5. Redis (master) and redis (slave) modify the redis.conf configuration file as follows:
vi /etc/redis.conf #Modify daemonize no daemonize yes #The unified platform modifies timeout 30, and the idle link is closed for 30 seconds timeout 30 #Modify the log storage location logfile /home/redis/logs/redis.log #Modify the dbfile directory from the compiled file directory to the following directory dir / home / redis / db
6. Modify the following configuration files for all three
vi /etc/sentinel.conf
#Modify the ip of 127.0.0.1 to any one of the redis master
sentinel monitor mymaster 117.79.146.5 6379 1
7. Create a new log and bdfile storage directory before starting, otherwise an error will be reported
mkdir -p /home/redis/logs mkdir -p /home/redis/db
8. Start the redis service
/home/redis/bin/redis-server /etc/redis.conf
9. Specify the redis of the local 6379 as the slave service of 117.79.146.5
/home/redis/bin/redis-cli slaveof 117.79.146.5 6379
10. Start the sentinel service (remember to use nohup)
nohup /home/redis/bin/redis-server /etc/sentinel.conf --sentinel &
11. Stop the redis service
/home/redis/bin/redis-cli -h localhost -p 6379 shutdown
12. Stop the sentinel service
/home/redis/bin/redis-cli -h localhost -p 26379 shutdown