First, the Environment preparation
master:192.168.1.203
slave:192.168.1.202
Redis is already installed, firewall and SELinux are turned off
Second, Redis master-slave configuration
Master config file does not move
Add the following on the slave configuration file:
Slaveof 192.168.1.203 6379 (primary server IP and Redis port number)
Masterauth passwd//master server password, if there is no can not add
Start master and slave, respectively
Test master/Slave configuration is successful, create a key on the master server
Set Key1 Fansik
From the server to see if there is this key on the server.
Get Key1
Third, Redis master-slave Other related configuration
Slave-read-only Yes #让从只读
Repl-ping-slave-period #设置slave向master发起ping的频率, launched every 10 seconds
Repl-timeout #设置slave Ping does not pass the master number of S after the timeout
Repl-disable-tcp-nodelay no #是否开启tcp_nodelay, will use less bandwidth when turned on, but there will be a delay, so it is recommended to close
Repl-backlog-size 1MB #同步队列的长度, Backuplog is a buffer of master, master will write the data to the buffer after the master and slave disconnects, and the slave will synchronize the data from the buffer.
Repl-backlog-ttl 3600 #主从断开后, buffer expiration, default 1 hours
Slave-priority #多个slave是可以设置优先级的, the lower the value of the higher priority, applied to the cluster, support slave switch to master, the highest priority will be switched
Min-slaves-to-write 3 #和下面的一起使用, he means that Master has found that more than 3 slave have a delay of more 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
Redis Master-Slave configuration