集群规划:
三台服务器各部署一个集群节点、一个哨兵进程。
服务器 |
角色 |
IP和端口 |
master1 |
master1/sentinel |
192.168.146.199 redis端口:6379 Sentinel端口:26379 |
slave1 |
slave1/sentinel |
192.168.146.200 redis端口:6379 Sentinel端口:26379 |
slave2 |
slave2/sentinel |
192.168.146.201 redis端口:6379 Sentinel端口:26379 |
命令行开头为#表示在所有主机上操作,命令行开后为具体主机名则表示在该主机上操作。
1、三台服务器基础设置
设置主机名:
# hostnamectl --static set-hostname master1/slave1/slave2 # vi /etc/hosts 192.168.146.199 master1 192.168.146.200 slave1 192.168.146.201 slave2
时区调整,时间校准:
# date -R # timedatectl set-timezone Asia/Shanghai # yum -y install ntp # ntpdate ntp1.aliyun.com
安装wget:
$ yum install -y wget
关闭selinux:
# vi /etc/sysconfig/selinux SELINUX=disabled
重启服务器并验证:
# getenforce Disabled
# 设置防火墙
# firewall-cmd --zone=public --add-port=6379/tcp --permanent success # firewall-cmd --zone=public --add-port=26379/tcp --permanent success # firewall-cmd --permanent --zone=public --list-ports 6379/tcp 26379/tcp # firewall-cmd --reload success
2、gcc版本问题避免
# yum -y install gcc tcl # yum -y install centos-release-scl # yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
查看gcc版本:
# gcc -v scl只是临时启用,退出shell后会恢复原系统gcc版本: # scl enable devtoolset-9 bash 如下命令表示永久启用: # echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile 查看gcc版本: # gcc -v
3、redis安装
# cd /opt # wget http://download.redis.io/releases/redis-6.0.8.tar.gz # tar zxvf redis-6.0.8.tar.gz # cd redis-6.0.8 # make MALLOC=libc # make test
将执行文件弄到环境变量所在目录:
# make install
临时启动测试:
# redis-server # ps -ef | grep redis root 17830 8648 0 23:14 pts/0 00:00:00 redis-server *:6379 # redis-cli 127.0.0.1:6379> set foo bar OK 127.0.0.1:6379> get foo "bar"
创建日志文件存放目录:
# mkdir -p /opt/redis/{data,conf,redis-log,sentinel-log}
4、修改配置文件
# cat /opt/redis-6.0.8/redis.conf | grep -v ^#|grep -v ^$ >/opt/redis/conf/redis.conf [root@master1 redis-6.0.8]# vim /opt/redis/conf/redis.conf #修改配置 bind 0.0.0.0 dir "/opt/redis/data" daemonize yes logfile "/opt/redis/redis-log/redis.log" #增加配置 requirepass 123456789 masterauth 123456789 [root@slave1 redis-6.0.8]# vim /opt/redis/conf/redis.conf #修改配置 bind 0.0.0.0 dir "/opt/redis/data" daemonize yes logfile "/opt/redis/redis-log/redis.log" #增加配置 requirepass 123456789 masterauth 123456789 slaveof 192.168.146.199 6379 [root@slave2 redis-6.0.8]# vim /opt/redis/conf/redis.conf #修改配置 bind 0.0.0.0 dir "/opt/redis/data" daemonize yes logfile "/opt/redis/redis-log/redis.log" #增加配置 requirepass 123456789 masterauth 123456789 slaveof 192.168.146.199 6379 # redis-server /opt/redis/conf/redis.conf # vim /etc/systemd/system/redis-server.service [Unit] Description=redis After=network.target [Service] Type=forking PIDFile=/var/run/redis_6379.pid ExecStart=/usr/local/bin/redis-server /opt/redis/conf/redis.conf ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown PrivateTmp=true [Install] WantedBy=multi-user.target # systemctl daemon-reload # systemctl enable redis-server.service
5、测试
[root@master1 redis-6.0.8]# redis-cli -h 192.168.146.199 -p 6379 -a 123456789 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.146.200,port=6379,state=online,offset=840,lag=1 slave1:ip=192.168.146.201,port=6379,state=online,offset=840,lag=0 master_replid:f0606a36a86526fd523beada6bc1d86c91be4162 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:840 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:840 [root@master1 redis-6.0.8]# redis-cli -h 192.168.146.199 -p 6379 -a 123456789 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.146.199:6379> AUTH 123456789 OK 192.168.146.199:6379> set k1 v1 OK 192.168.146.199:6379> exit [root@master1 redis-6.0.8]# redis-cli -h 192.168.146.200 -p 6379 -a 123456789 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.146.200:6379> get k1 "v1" 192.168.146.200:6379> exit [root@master1 redis-6.0.8]# redis-cli -h 192.168.146.201 -p 6379 -a 123456789 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.146.201:6379> get k1 "v1"
6、安装哨兵sentinel
# cd /opt/redis-6.0.8/ # cat sentinel.conf | grep -v ^#|grep -v ^$ >/opt/redis/conf/sentinel.conf # vim /opt/redis/conf/sentinel.conf port 26379 daemonize yes pidfile /var/run/redis-sentinel.pid logfile "/opt/redis/sentinel-log/sentinel.log" dir /tmp sentinel monitor mymaster 192.168.146.199 6379 2 sentinel down-after-milliseconds mymaster 30000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 180000 sentinel deny-scripts-reconfig yes sentinel auth-pass mymaster 123456789 # redis-sentinel /opt/redis/conf/sentinel.conf # ps -ef | grep sentinel root 27794 1 0 18:29 ? 00:00:00 redis-sentinel *:26379 [sentinel] root 27799 7667 0 18:30 pts/0 00:00:00 grep --color=auto sentinel # vim /etc/systemd/system/redis-sentinel.service [Unit] Description=The redis-sentinel Process Manager After=syslog.target network.target [Service] Type=forking PIDFile=/var/run/redis-sentinel.pid ExecStart=/usr/local/bin/redis-sentinel /opt/redis/conf/sentinel.conf ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 26379 PrivateTmp=true [Install] WantedBy=multi-user.target # systemctl daemon-reload # systemctl enable redis-sentinel.service
7、测试sentinel
[root@master1 src]# redis-cli -h 192.168.146.199 -p 6379 -a 123456789 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.146.200,port=6379,state=online,offset=78659,lag=0 slave1:ip=192.168.146.201,port=6379,state=online,offset=78369,lag=0 master_replid:f0606a36a86526fd523beada6bc1d86c91be4162 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:78659 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:78659 [root@slave1 redis-6.0.8]# redis-cli -h 192.168.146.200 -p 6379 -a 123456789 info Replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:slave master_host:192.168.146.199 master_port:6379 master_link_status:up master_last_io_seconds_ago:0 master_sync_in_progress:0 slave_repl_offset:93257 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:f0606a36a86526fd523beada6bc1d86c91be4162 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:93257 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:93257 [root@slave2 redis-6.0.8]# redis-cli -h 192.168.146.201 -p 6379 -a 123456789 info Replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:slave master_host:192.168.146.199 master_port:6379 master_link_status:up master_last_io_seconds_ago:0 master_sync_in_progress:0 slave_repl_offset:96316 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:f0606a36a86526fd523beada6bc1d86c91be4162 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:96316 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:96316 kill掉master节点的redis进程 [root@master1 src]# ps -ef | grep redis root 17437 1 0 01:36 ? 00:00:11 redis-server 0.0.0.0:6379 root 17580 1 0 02:38 ? 00:00:00 redis-sentinel *:26379 [sentinel] root 17591 7794 0 02:40 pts/0 00:00:00 grep --color=auto redis [root@master1 src]# kill 17437 [root@master1 src]# ps -ef | grep redis root 17580 1 0 02:38 ? 00:00:00 redis-sentinel *:26379 [sentinel] root 17593 7794 0 02:40 pts/0 00:00:00 grep --color=auto redis master报错和sentinel日志 [root@master1 src]# redis-cli -h 192.168.146.199 -p 6379 -a 123456789 info Replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. Could not connect to Redis at 192.168.146.199:6379: Connection refused [root@master1 ~]# tail -f /opt/redis/sentinel-log/sentinel.log 6988:X 21 Sep 2020 18:12:38.244 # +sdown master mymaster 192.168.146.199 6379 6988:X 21 Sep 2020 18:12:38.357 # +new-epoch 3 6988:X 21 Sep 2020 18:12:38.358 # +vote-for-leader ab9c4405bb88e1177244fa31f5b3ba92ea182663 3 6988:X 21 Sep 2020 18:12:38.803 # +config-update-from sentinel ab9c4405bb88e1177244fa31f5b3ba92ea182663 192.168.146.201 26379 @ mymaster 192.168.146.199 6379 6988:X 21 Sep 2020 18:12:38.804 # +switch-master mymaster 192.168.146.199 6379 192.168.146.200 6379 6988:X 21 Sep 2020 18:12:38.806 * +slave slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.200 6379 6988:X 21 Sep 2020 18:12:38.806 * +slave slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 6988:X 21 Sep 2020 18:13:08.811 # +sdown slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 slave1角色提升为master了 [root@slave1 redis-6.0.8]# redis-cli -h 192.168.146.200 -p 6379 -a 123456789 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:1 slave0:ip=192.168.146.201,port=6379,state=online,offset=142177,lag=1 master_replid:3bb8123f95fd1bd75d6c747a2eb87d7983eb0124 master_replid2:f0606a36a86526fd523beada6bc1d86c91be4162 master_repl_offset:142612 second_repl_offset:134283 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:142612 [root@slave1 ~]# tail -f /opt/redis/sentinel-log/sentinel.log 6966:X 21 Sep 2020 10:12:39.483 # +sdown master mymaster 192.168.146.199 6379 6966:X 21 Sep 2020 10:12:39.526 # +new-epoch 3 6966:X 21 Sep 2020 10:12:39.528 # +vote-for-leader ab9c4405bb88e1177244fa31f5b3ba92ea182663 3 6966:X 21 Sep 2020 10:12:39.583 # +odown master mymaster 192.168.146.199 6379 #quorum 3/2 6966:X 21 Sep 2020 10:12:39.583 # Next failover delay: I will not start a failover before Mon Sep 21 10:18:40 2020 6966:X 21 Sep 2020 10:12:39.975 # +config-update-from sentinel ab9c4405bb88e1177244fa31f5b3ba92ea182663 192.168.146.201 26379 @ mymaster 192.168.146.199 6379 6966:X 21 Sep 2020 10:12:39.975 # +switch-master mymaster 192.168.146.199 6379 192.168.146.200 6379 6966:X 21 Sep 2020 10:12:39.976 * +slave slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.200 6379 6966:X 21 Sep 2020 10:12:39.976 * +slave slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 6966:X 21 Sep 2020 10:13:10.027 # +sdown slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 slave2角色依然不变 [root@slave2 redis-6.0.8]# redis-cli -h 192.168.146.201 -p 6379 -a 123456789 info Replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:slave master_host:192.168.146.200 master_port:6379 master_link_status:up master_last_io_seconds_ago:0 master_sync_in_progress:0 slave_repl_offset:146120 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:3bb8123f95fd1bd75d6c747a2eb87d7983eb0124 master_replid2:f0606a36a86526fd523beada6bc1d86c91be4162 master_repl_offset:146120 second_repl_offset:134283 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:146120 [root@slave2 ~]# tail -f /opt/redis/sentinel-log/sentinel.log 6984:X 21 Sep 2020 10:12:38.829 # +sdown master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:38.881 # +odown master mymaster 192.168.146.199 6379 #quorum 2/2 6984:X 21 Sep 2020 10:12:38.881 # +new-epoch 3 6984:X 21 Sep 2020 10:12:38.881 # +try-failover master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:38.883 # +vote-for-leader ab9c4405bb88e1177244fa31f5b3ba92ea182663 3 6984:X 21 Sep 2020 10:12:38.888 # 723d1c7577f14dd054538e82a460624471549c4f voted for ab9c4405bb88e1177244fa31f5b3ba92ea182663 3 6984:X 21 Sep 2020 10:12:38.888 # 52fdac69ed34c60e71f5604ea9c4f5a93e5de62f voted for ab9c4405bb88e1177244fa31f5b3ba92ea182663 3 6984:X 21 Sep 2020 10:12:38.935 # +elected-leader master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:38.935 # +failover-state-select-slave master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.027 # +selected-slave slave 192.168.146.200:6379 192.168.146.200 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.027 * +failover-state-send-slaveof-noone slave 192.168.146.200:6379 192.168.146.200 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.082 * +failover-state-wait-promotion slave 192.168.146.200:6379 192.168.146.200 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.260 # +promoted-slave slave 192.168.146.200:6379 192.168.146.200 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.260 # +failover-state-reconf-slaves master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.330 * +slave-reconf-sent slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:39.997 # -odown master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:40.275 * +slave-reconf-inprog slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:40.276 * +slave-reconf-done slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:40.336 # +failover-end master mymaster 192.168.146.199 6379 6984:X 21 Sep 2020 10:12:40.337 # +switch-master mymaster 192.168.146.199 6379 192.168.146.200 6379 6984:X 21 Sep 2020 10:12:40.338 * +slave slave 192.168.146.201:6379 192.168.146.201 6379 @ mymaster 192.168.146.200 6379 6984:X 21 Sep 2020 10:12:40.338 * +slave slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 6984:X 21 Sep 2020 10:13:10.350 # +sdown slave 192.168.146.199:6379 192.168.146.199 6379 @ mymaster 192.168.146.200 6379 关闭slave1的redis,这个时候主节点重新回到master了 [root@slave1 ~]# systemctl stop redis-server slave1的redis日志 [root@slave1 ~]# tail -f /opt/redis/redis-log/redis.log 6965:signal-handler (1600653447) Received SIGTERM scheduling shutdown... 6965:M 21 Sep 2020 09:57:27.635 # User requested shutdown... 6965:M 21 Sep 2020 09:57:27.635 * Saving the final RDB snapshot before exiting. 6965:M 21 Sep 2020 09:57:27.636 * DB saved on disk 6965:M 21 Sep 2020 09:57:27.636 * Removing the pid file. 6965:M 21 Sep 2020 09:57:27.636 # Redis is now ready to exit, bye bye... slave2的redis日志 [root@slave2 ~]# tail -f /opt/redis/redis-log/redis.log 6985:S 21 Sep 2020 09:57:26.996 # Connection with master lost. 6985:S 21 Sep 2020 09:57:26.996 * Caching the disconnected master state. 6985:S 21 Sep 2020 09:57:27.978 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:27.979 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:27.979 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:28.986 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:28.986 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:28.987 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:29.992 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:29.992 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:29.992 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:30.999 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:31.000 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:31.000 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:32.005 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:32.005 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:32.006 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:33.015 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:33.015 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:33.015 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:34.021 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:34.021 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:34.022 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:35.029 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:35.029 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:35.030 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:36.039 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:36.039 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:36.040 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:37.045 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:37.046 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:37.046 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:38.053 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:38.054 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:38.054 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:39.061 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:39.061 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:39.061 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:40.067 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:40.068 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:40.068 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:41.075 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:41.076 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:41.076 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:42.084 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:42.084 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:42.085 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:43.093 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:43.093 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:43.093 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:44.099 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:44.100 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:44.100 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:45.109 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:45.109 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:45.109 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:46.116 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:46.117 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:46.117 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:47.126 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:47.126 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:47.126 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:48.134 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:48.134 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:48.134 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:49.143 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:49.143 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:49.144 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:50.150 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:50.150 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:50.150 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:51.159 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:51.159 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:51.160 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:52.167 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:52.167 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:52.168 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:53.176 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:53.176 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:53.176 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:54.182 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:54.182 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:54.183 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:55.196 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:55.196 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:55.196 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:56.203 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:56.203 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:56.203 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:57.212 * Connecting to MASTER 192.168.146.200:6379 6985:S 21 Sep 2020 09:57:57.212 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:57.213 # Error condition on socket for SYNC: Operation now in progress 6985:S 21 Sep 2020 09:57:57.737 * REPLICAOF 192.168.146.199:6379 enabled (user request from 'id=10 addr=192.168.146.199:58856 fd=12 name=sentinel-52fdac69-cmd age=180 idle=0 flags=x db=0 sub=0 psub=0 multi=4 qbuf=348 qbuf-free=32420 obl=45 oll=0 omem=0 events=r cmd=exec user=default') 6985:S 21 Sep 2020 09:57:57.742 # CONFIG REWRITE executed with success. 6985:S 21 Sep 2020 09:57:58.221 * Connecting to MASTER 192.168.146.199:6379 6985:S 21 Sep 2020 09:57:58.221 * MASTER <-> REPLICA sync started 6985:S 21 Sep 2020 09:57:58.221 * Non blocking connect for SYNC fired the event. 6985:S 21 Sep 2020 09:57:58.222 * Master replied to PING, replication can continue... 6985:S 21 Sep 2020 09:57:58.224 * Trying a partial resynchronization (request 5367f0d48f38f90ba4049735d2e5a05383b8c82c:33172). 6985:S 21 Sep 2020 09:57:58.224 * Successful partial resynchronization with master. 6985:S 21 Sep 2020 09:57:58.224 # Master replication ID changed to b721365a9406093b0567f283d63268ff475308bc 6985:S 21 Sep 2020 09:57:58.224 * MASTER <-> REPLICA sync: Master accepted a Partial Resynchronization. master的redis日志 [root@master1 ~]# tail -f /opt/redis/redis-log/redis.log 6989:S 21 Sep 2020 17:57:26.467 # Connection with master lost. 6989:S 21 Sep 2020 17:57:26.467 * Caching the disconnected master state. 6989:S 21 Sep 2020 17:57:27.029 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:27.029 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:27.030 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:28.037 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:28.037 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:28.037 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:29.044 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:29.045 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:29.045 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:30.052 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:30.053 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:30.053 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:31.062 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:31.062 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:31.062 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:32.070 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:32.070 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:32.071 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:33.075 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:33.075 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:33.076 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:34.083 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:34.083 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:34.083 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:35.090 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:35.090 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:35.091 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:36.099 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:36.099 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:36.099 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:37.107 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:37.107 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:37.107 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:38.117 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:38.117 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:38.118 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:39.123 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:39.124 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:39.124 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:40.130 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:40.130 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:40.130 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:41.138 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:41.138 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:41.138 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:42.145 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:42.145 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:42.145 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:43.153 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:43.153 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:43.153 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:44.159 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:44.159 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:44.160 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:45.167 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:45.167 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:45.167 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:46.175 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:46.175 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:46.177 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:47.181 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:47.181 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:47.181 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:48.188 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:48.188 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:48.188 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:49.196 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:49.196 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:49.196 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:50.203 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:50.203 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:50.203 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:51.211 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:51.211 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:51.211 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:52.219 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:52.219 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:52.219 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:53.227 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:53.227 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:53.227 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:54.234 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:54.234 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:54.235 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:55.245 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:55.245 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:55.245 # Error condition on socket for SYNC: Operation now in progress 6989:S 21 Sep 2020 17:57:56.253 * Connecting to MASTER 192.168.146.200:6379 6989:S 21 Sep 2020 17:57:56.253 * MASTER <-> REPLICA sync started 6989:S 21 Sep 2020 17:57:56.254 # Error condition on socket for SYNC: Operation now in progress 6989:M 21 Sep 2020 17:57:56.859 * Discarding previously cached master state. 6989:M 21 Sep 2020 17:57:56.859 # Setting secondary replication ID to 5367f0d48f38f90ba4049735d2e5a05383b8c82c, valid up to offset: 33172. New replication ID is b721365a9406093b0567f283d63268ff475308bc 6989:M 21 Sep 2020 17:57:56.860 * MASTER MODE enabled (user request from 'id=5 addr=192.168.146.199:53524 fd=7 name=sentinel-52fdac69-cmd age=180 idle=0 flags=x db=0 sub=0 psub=0 multi=4 qbuf=188 qbuf-free=32580 obl=45 oll=0 omem=0 events=r cmd=exec user=default') 6989:M 21 Sep 2020 17:57:56.863 # CONFIG REWRITE executed with success. 6989:M 21 Sep 2020 17:57:57.695 * Replica 192.168.146.201:6379 asks for synchronization 6989:M 21 Sep 2020 17:57:57.695 * Partial resynchronization request from 192.168.146.201:6379 accepted. Sending 458 bytes of backlog starting from offset 33172.