标签:mymaster 10.0 17 6379 0.101 Redis sentinel Sentinel
基于主从基础上,修改redis-sentinel.conf, scp到其他redis机器,再重新启动redis-sentinel.service [17:33:43 root@localhost ~]#grep -v "^#" /etc/redis-sentinel.conf port 26379 daemonize no pidfile "/var/run/redis-sentinel.pid" logfile "/var/log/redis/sentinel.log" -》 sentinel log dir "/tmp" sentinel myid fbe3ed27d75c32f1671571684d21af464c2d7588 -》 自动生成的唯一ID sentinel deny-scripts-reconfig yes sentinel monitor mymaster 10.0.0.103 6379 2 -》 master IP sentinel down-after-milliseconds mymaster 3000 -》 投票时间 sentinel auth-pass mymaster 123456 -》 验证 sentinel config-epoch mymaster 1 protected-mode no supervised systemd sentinel leader-epoch mymaster 1 sentinel known-replica mymaster 10.0.0.102 6379 sentinel known-replica mymaster 10.0.0.101 6379 sentinel known-sentinel mymaster 10.0.0.101 26379 34e1ca1b533dcc6c8c8fa88101303ce154c42fd7 sentinel known-sentinel mymaster 10.0.0.102 26379 6fcdcac00226e0f45947c58389068db550e879aa sentinel current-epoch 1 ############# 查看结果 [17:31:29 root@localhost ~]#redis-cli -a 123456 -p 26379 info sentinel Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Sentinel sentinel_masters:1 sentinel_tilt:0 sentinel_running_scripts:0 sentinel_scripts_queue_length:0 sentinel_simulate_failure_flags:0 master0:name=mymaster,status=ok,address=10.0.0.101:6379,slaves=2,sentinels=3 #####挂掉当前主redis [17:31:40 root@localhost ~]#killall redis-server ## 在其他redis上面查看sentinel日志 [17:32:52 root@localhost ~]#tail -f /var/log/redis/sentinel.log 1698:X 07 Oct 2021 17:33:25.497 # +sdown master mymaster 10.0.0.101 6379 1698:X 07 Oct 2021 17:33:25.588 # +new-epoch 1 1698:X 07 Oct 2021 17:33:25.588 # +vote-for-leader 6fcdcac00226e0f45947c58389068db550e879aa 1 1698:X 07 Oct 2021 17:33:26.621 # +odown master mymaster 10.0.0.101 6379 #quorum 3/2 1698:X 07 Oct 2021 17:33:26.621 # Next failover delay: I will not start a failover before Thu Oct 7 17:39:26 2021 1698:X 07 Oct 2021 17:33:26.691 # +config-update-from sentinel 6fcdcac00226e0f45947c58389068db550e879aa 10.0.0.102 26379 @ mymaster 10.0.0.101 6379 1698:X 07 Oct 2021 17:33:26.691 # +switch-master mymaster 10.0.0.101 6379 10.0.0.103 6379 1698:X 07 Oct 2021 17:33:26.691 * +slave slave 10.0.0.102:6379 10.0.0.102 6379 @ mymaster 10.0.0.103 6379 1698:X 07 Oct 2021 17:33:26.691 * +slave slave 10.0.0.101:6379 10.0.0.101 6379 @ mymaster 10.0.0.103 6379 1698:X 07 Oct 2021 17:33:29.719 # +sdown slave 10.0.0.101:6379 10.0.0.101 6379 @ mymaster 10.0.0.103 6379 ## 通过投票,10.0.0.103成为新的主 [17:32:15 root@localhost ~]#redis-cli -a 123456 -p 26379 info sentinel Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Sentinel sentinel_masters:1 sentinel_tilt:0 sentinel_running_scripts:0 sentinel_scripts_queue_length:0 sentinel_simulate_failure_flags:0 master0:name=mymaster,status=ok,address=10.0.0.103:6379,slaves=2,sentinels=3 ## 10.0.0.101重启变成slave [17:34:16 root@localhost ~]#redis-cli -a 123456 -p 26379 info sentinel Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Sentinel sentinel_masters:1 sentinel_tilt:0 sentinel_running_scripts:0 sentinel_scripts_queue_length:0 sentinel_simulate_failure_flags:0 master0:name=mymaster,status=ok,address=10.0.0.103:6379,slaves=2,sentinels=3 1698:X 07 Oct 2021 17:34:08.258 # -sdown slave 10.0.0.101:6379 10.0.0.101 6379 @ mymaster 10.0.0.103 6379 1698:X 07 Oct 2021 17:34:18.201 * +convert-to-slave slave 10.0.0.101:6379 10.0.0.101 6379 @ mymaster 10.0.0.103 6379
标签:mymaster,10.0,17,6379,0.101,Redis,sentinel,Sentinel 来源: https://www.cnblogs.com/noise/p/15376664.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。