1: persistence is not enabled in the redis master-slave environment. When the master instance goes down, data from the instance is not affected. When the master instance recovers, data on the master instance will be synchronized to the slave instance, that is, the original value will change to a null value; [root @ ser
1: persistence is not enabled in the redis master-slave environment. When the master instance goes down, data from the instance is not affected. When the master instance recovers, data on the master instance will be synchronized to the slave instance, that is, the original value will change to a null value; [root @ ser
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;
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123 info | grep-A 3 'replicase'
# Replication
Role: master
Connected_slaves: 1
Slave0: 192.168.1.113, 6379, online
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> set 1
OK
Redis 192.168.1.112: 6379> get 1
""
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123 shutdown
[Root @ server12 ~] # Tail-f/var/log/messages
Dec 3 15:27:34 server12 redis [32151]: Connecting to MASTER...
Dec 3 15:27:34 server12 apsaradb for redis [32151]: MASTER <-> SLAVE sync started
Dec 3 15:27:34 server12 redis [32151]: Error condition on socket for SYNC: Connection refused
[Root @ server12 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
""
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-server/usr/local/redis2/etc/redis. conf
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> get 1
(Nil)
Redis 192.168.1.112: 6379> exit
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
(Nil)
2: redis master-slave environment, Hong Kong server, enabling snapshot persistence from instance
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;
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> get 1
(Nil)
Redis 192.168.1.112: 6379> set 1
OK
Redis 192.168.1.112: 6379> set 2 B
OK
Redis 192.168.1.112: 6379> exit
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123 shutdown
[Root @ server12 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
""
Redis 192.168.1.113: 6379> get 2
"B"
Redis 192.168.1.113: 6379> exit
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> get 1
(Nil)
Redis 192.168.1.112: 6379> get 2
(Nil)
Redis 192.168.1.112: 6379> exit
[Root @ server12 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
(Nil)
Redis 192.168.1.113: 6379> get 2
(Nil)
Redis 192.168.1.113: 6379> exit
3: What happens when the master and slave instances are down?
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> set 1
OK
Redis 192.168.1.112: 6379> set 2 B
OK
Redis 192.168.1.112: 6379> set 3 c
OK
Redis 192.168.1.112: 6379> exit
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
""
Redis 192.168.1.113: 6379> get 2
"B"
Redis 192.168.1.113: 6379> get 3
"C"
Redis 192.168.1.113: 6379> exit
This time, first shut down the instance, the Hong Kong server rented, and then the master instance! Start the slave instance, test data, and then start the master instance, the U.S. space, and then test data!
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123 shutdown
[Root @ server12 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123 shutdown
[Root @ server12 ~] #/Usr/local/redis2/bin/redis-server/usr/local/redis2/etc/redis. conf
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
""
Redis 192.168.1.113: 6379> get 2
"B"
Redis 192.168.1.113: 6379> get 3
"C"
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-server/usr/local/redis2/etc/redis. conf
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.112-a 123
Redis 192.168.1.112: 6379> get 1
(Nil)
Redis 192.168.1.112: 6379> get 2
(Nil)
Redis 192.168.1.112: 6379> get 3
(Nil)
Redis 192.168.1.112: 6379> exit
[Root @ server11 ~] #/Usr/local/redis2/bin/redis-cli-h 192.168.1.113-a 123
Redis 192.168.1.113: 6379> get 1
(Nil)
Redis 192.168.1.113: 6379> get 2
(Nil)
Redis 192.168.1.113: 6379> get 3
(Nil)
Redis 192.168.1.113: 6379> exit
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!