The gcc environment is installed on the system (otherwise, compiling redis will cause errors).Still don't know how to install the gcc environment offline viewable Install gcc environment offline under CentOS with detailed graphics
download
Click on the official address to download redis for Linux
http://download.redis.io/releases/redis-5.0.4.tar.gz
upload
put D:\AppStore\redis\redis-5.0.4.tar.gz /root
install
tar xzf redis-5.0.4.tar.gz mv redis-5.0.4 /usr/local/redis cd /usr/local/redis/redis-5.0.4 make make install
If make errors occur as follows
Fatal error: jemalloc/jemalloc.h: No file or directory
Then use
make MALLOC=libc
Node Configuration
Now you have three virtual machines, you can do it all the time.Enter redis.conf and change as follows
192.168.1.115 (primary node)
bind 192.168.1.115 daemonize yes masterauth 666666 requirepass 666666 pidfile /st/redis/pid/redis_6379.pid logfile "/st/redis/log/redis.log" dir /st/redis/db/
192.168.1.113 (from Node 1)
bind 192.168.1.113 daemonize yes masterauth 666666 requirepass 666666 replicaof 192.168.1.115 6379 pidfile /st/redis/pid/redis_6379.pid logfile "/st/redis/log/redis.log" dir /st/redis/db/
192.168.1.112 (from Node 2)
bind 192.168.1.112 daemonize yes masterauth 666666 requirepass 666666 replicaof 192.168.1.115 6379 pidfile /st/redis/pid/redis_6379.pid logfile "/st/redis/log/redis.log" dir /st/redis/db/
Sentry Configuration
Now that you have three virtual machines, don't waste it; just pair three sentries on them.However, if a server is hung, the node will be hung, and the sentry on that server will be hung, but there are still two senders who can work, so it is acceptable.Otherwise, set up separate servers for the sentry.
Enter sentinel.conf and change as follows
192.168.1.115
daemonize yes sentinel monitor mymaster 192.168.1.115 6379 2 sentinel auth-pass mymaster 666666 pidfile /st/redis/pid/redis-sentinel.pid logfile "/st/redis/log/redis-sentinel.log" dir /st/redis/tmp
192.168.1.113
daemonize yes sentinel monitor mymaster 192.168.1.115 6379 2 sentinel auth-pass mymaster 666666 pidfile /st/redis/pid/redis-sentinel.pid logfile "/st/redis/log/redis-sentinel.log" dir /st/redis/tmp
192.168.1.112
daemonize yes sentinel monitor mymaster 192.168.1.115 6379 2 sentinel auth-pass mymaster 666666 pidfile /st/redis/pid/redis-sentinel.pid logfile "/st/redis/log/redis-sentinel.log" dir /st/redis/tmp
Start Node
From primary to secondary, each node runs and checks
/usr/local/redis/redis-5.0.4/src/redis-server /usr/local/redis/redis-5.0.4/redis.conf netstat -tulnp |grep redis
Start Sentinel
Each Sentinel runs and checks
/usr/local/redis/redis-5.0.4/src/redis-sentinel /usr/local/redis/redis-5.0.4/sentinel.conf ps -ef |grep redis
inspect
Check master-slave replication, log in to the master node to write information and see if the information is received from the node
/usr/local/redis/redis-5.0.4/src/redis-cli -h 192.168.1.115 auth 666666 set name 'lgx'
Log on from the node to see if you can receive information
/usr/local/redis/redis-5.0.4/src/redis-cli -h 192.168.1.113 auth 666666 get name 'lgx'
Check Sentinel Monitoring
/usr/local/redis/redis-5.0.4/src/redis-sentinel -p 26379 sentinel master mymaster
Register a global directory if you dislike using the previous heap of commands
ln -s /usr/local/redis/redis-5.0.4/src/redis-sentinel /usr/bin/redis-sentinel ln -s /usr/local/redis/redis-5.0.4/src/redis-server /usr/bin/redis-server ln -s /usr/local/redis/redis-5.0.4/src/redis-cli /usr/bin/redis-cli
Matters needing attention
On production remember to check: firewall, security group, redis password, bound ip, storage directory of each file.
This is the default directory to avoid forgetting the configuration and not knowing where to put it.
#redis node pidfile /var/run/redis_6379.pid logfile "" dbfilename dump.rdb dir ./ #redis Sentinel pidfile /var/run/redis-sentinel.pid logfile "" dir /tmp
This is adding node ports, sentry ports to the firewall
firewall-cmd --permanent --add-port=6379/tcp firewall-cmd --permanent --add-port=26379/tcp//Add a port firewall-cmd --reload //Then reload
Test Report
When the primary node is down, it restarts immediately. It takes some time, about a few seconds, for the primary node to switch. During this time, if you operate redis, the operation will fail because the connection to the primary node is unsuccessful.
When switching, the configuration of the node and the sentry is automatically modified, such as the replicaof parameter from the node and sentinel monitor mymaster parameter from the sentry.
After the downtime restarts, nodes and sentries cannot recover automatically and need to be started manually.I thought daemonize yes means start-up and start-up. It could have been run in the background or exit the redis command line page.