The master-slave setting of reids is easy to complete in just one sentence. Add it in the slave configuration file redis. conf.
Slaveof 192.168.252.20.5371
192.168.252.20.host IP 5371 is the host port
Start the host and then start the slave. To improve performance, you can set persistence settings for the host instead of for the slave.
If you need a password: Set requirepass 123456 123456 as the password on the host.
Set masterauth 123456 123456 as the password on the slave
Note that when the host goes down, do not start the host instance first. Otherwise, the slave data will be cleared !!!!, Remember.
1: persistence is not enabled in the redis Master/Slave environment;
When the master instance goes down, data from the instance is not affected;
After the master instance recovers, the data on the master instance will continue to be synchronized to the slave instance, that is, the original value will change to NULL;
2: Enable snapshot persistence from the instance in redis master-slave Environment
When the master instance goes down, data from the instance is not affected;
After the master instance recovers, the data on the master instance will continue to be synchronized to the slave instance, that is, the original value will change to NULL;
3: What happens when the master and slave instances are down?
Disable the slave instance and then the master instance! Start the slave instance, test data, and then start the master instance, and then test data!
Practice has proved that, under the condition of redis master-slave read/write splitting, snapshot persistence can only be enabled on the master instance side to ensure that data can be restarted across instances!