docker exec -it redis-server redis-cli -p 6379 -a 123456 info replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:master connected_slaves:2 slave0:ip=192.168.91.142,port=6379,state=online,offset=59312,lag=0 slave1:ip=192.168.91.141,port=6379,state=online,offset=59312,lag=0 master_failover_state:no-failover master_replid:d6b4569077d75635dfc115546c4197506b337ee6 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:59312 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:59312
关闭主节点redis服务,验证从节点是否切换为主节点
docker exec -it redis-sentinel redis-cli -p 6379 -a 123456 info replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:master connected_slaves:2 slave0:ip=192.168.91.141,port=6379,state=online,offset=84559,lag=1 slave1:ip=192.168.91.140,port=6379,state=online,offset=84716,lag=1 master_failover_state:no-failover master_replid:3b26ded16e965bd71b7f617b7fd458e55dcdf4f2 master_replid2:d6b4569077d75635dfc115546c4197506b337ee6 master_repl_offset:84716 second_repl_offset:64802 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:84716