Redis installation Configuration Master-Slave # supports a master multi-slave, remember to close SELinux
Two servers: Master (192.168.31.105) and slave (192.168.31.112)
Install Redis and start with the steps described earlier
Master config file does not move
Add a row to the slave configuration file
Slaveof 192.168.31.105 6379
Masterauth Aminglinux//If the Lord sets a password, add this line
Start master and slave, respectively
Test Redis Master-Slave
On master:
Redis-cli
>set K1 v1
>get K1
"V1"
On slave:
Redis-cli
>get K1
"V1"
Redis Master-Slave Other related configurations
slave-read-only Yes //Let from read-only
repl-ping-slave-period //Set slave the frequency of pings to master, which is initiated every 10s. Detect survival
repl-timeout //Set slave ping does not pass the master number of S after the timeout
Repl-disable-tcp-nodelay No//open tcp_nodelay, will use less bandwidth, but there will be delay, so it is recommended to close
Repl-backlog-size 1MB//sync Queue Length, Backuplog is a buffer of master, master will write the data to the buffer, slave will synchronize the data from the buffer after the master disconnects.
Repl-backlog-ttl 3600//Master disconnect, buffer expiration, default 1 hours
slave-priority //Multiple Slave can be set priority, the lower the value of the higher priority, applied to the cluster, support slave switch to master, the highest priority will switch
Min-slaves-to-write 3//and used in conjunction with the following, it means that master found that there are more than 3 slave latency higher than 10s, then master will temporarily stop the write operation. If either of these values is 0, the function is turned off, and the default first value is 0.
Min-slaves-max-lag 10
2.2-redis Master-Slave configuration