我使用2.8 RC5 redis中的redis-sentinel
来监控和故障转移我的redis节点。设置如下:
Sentinel节点
Redis节点
slaveof
)在每个Sentinel节点上,我使用相同的配置:
sentinel monitor serverA serverA.mydomain.tld 6379 2
sentinel auth-pass serverA "MYAUTHPASS"
sentinel down-after-milliseconds serverA 10000
sentinel failover-timeout serverA 20000
sentinel can-failover serverA yes
sentinel parallel-syncs serverA 1
sentinel monitor serverB serverB.mydomain.tld 6379 4
sentinel auth-pass serverB "MYAUTHPASS"
sentinel down-after-milliseconds serverB 10000
sentinel failover-timeout serverB 20000
sentinel can-failover serverB yes
sentinel parallel-syncs serverB 5
我正在进行此测试:
现在,服务器A是服务器B的从属服务器,服务器A是服务器B的从属服务器。
这是一个错误还是错误的配置?
这些是步骤3(在服务器A上停止主服务器)后的标记日志
[19569] 17 Sep 18:33:28.873 # +sdown master serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:28.873 # +sdown master serverB serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:29.073 # +odown master serverA serverA.mydomain.tld 6379 #quorum 3/2
[19569] 17 Sep 18:33:29.073 # +failover-triggered master serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:29.073 # +failover-state-wait-start master serverA serverA.mydomain.tld 6379 #starting in 6543 milliseconds
[19569] 17 Sep 18:33:35.700 # +failover-state-select-slave master serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:35.800 # +selected-slave slave serverB.mydomain.tld:6379 serverB.mydomain.tld 6379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:35.800 * +failover-state-send-slaveof-noone slave serverB.mydomain.tld:6379 serverB.mydomain.tld 6379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:35.900 * +failover-state-wait-promotion slave serverB.mydomain.tld:6379 serverB.mydomain.tld 6379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:36.204 # +promoted-slave slave serverB.mydomain.tld:6379 serverB.mydomain.tld 6379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:36.204 # +failover-state-reconf-slaves master serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:36.302 # +failover-end master serverA serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:36.302 # +switch-master serverA serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:37.196 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:38.107 # +failover-detected master serverB serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:38.206 # +failover-end master serverB serverA.mydomain.tld 6379
[19569] 17 Sep 18:33:38.206 # +switch-master serverB serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:41.322 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:41.322 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:42.105 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:46.329 # +sdown slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:33:48.233 # +sdown slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverB serverB.mydomain.tld 6379
CONFIG GET slaveof
""
这些是再次启动服务器A(主服务器)后的日志(步骤5):
[19569] 17 Sep 18:53:08.305 * +demote-old-slave slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:53:08.306 * +demote-old-slave slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 18:53:08.506 # -sdown slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:53:08.506 # -sdown slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 18:53:18.319 * +slave slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:53:18.319 * +slave slave serverA.mydomain.tld:6379 serverA.mydomain.tld 6379 @ serverB serverB.mydomain.tld 6379
CONFIG GET slaveof
"serverB.mydomain.tld"
""
这些是停止服务器B(从属)后的日志:
[19569] 17 Sep 18:58:38.375 # +sdown master serverB serverB.mydomain.tld 6379
[19569] 17 Sep 18:58:38.675 # +sdown master serverA serverB.mydomain.tld 6379
[19569] 17 Sep 18:58:38.876 # +odown master serverA serverB.mydomain.tld 6379 #quorum 3/2
CONFIG GET slaveof
"serverB.mydomain.tld"
(此时似乎错了!)这些是再次启动服务器B(从属)后的日志:
[19569] 17 Sep 19:00:59.892 * +reboot master serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:00:59.892 # +redirect-to-master serverB serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:00:59.892 * +reboot master serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:00:59.892 # +redirect-to-master serverA serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:00.012 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:00.012 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:05.008 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:05.008 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:09.907 # +redirect-to-master serverA serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:09.907 # +redirect-to-master serverB serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:10.029 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:10.029 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:10.046 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:10.046 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:19.925 # +redirect-to-master serverA serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:19.925 # +redirect-to-master serverB serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:20.096 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:20.096 * +sentinel sentinel serverC.mydomain.tld:263
[19569] 17 Sep 19:01:20.096 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:20.096 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:20.143 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:20.143 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:29.943 # +redirect-to-master serverA serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:29.943 # +redirect-to-master serverB serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:30.037 - Reading from client: Connection reset by peer
[19569] 17 Sep 19:01:30.140 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:30.140 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:30.156 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:30.156 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:39.962 # +redirect-to-master serverA serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:39.962 # +redirect-to-master serverB serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:40.169 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:40.169 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:40.191 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:40.191 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:49.980 # +redirect-to-master serverA serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:49.980 # +redirect-to-master serverB serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:50.180 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:50.180 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:50.256 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:50.256 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:01:59.999 # +redirect-to-master serverA serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:01:59.999 # +redirect-to-master serverB serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:02:00.193 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:02:00.193 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:02:00.313 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:02:00.313 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:02:10.013 # +redirect-to-master serverA serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:02:10.013 # +redirect-to-master serverB serverA.mydomain.tld 6379 serverB.mydomain.tld 6379
[19569] 17 Sep 19:02:10.209 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:02:10.209 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
[19569] 17 Sep 19:02:10.450 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverB.mydomain.tld 6379
[19569] 17 Sep 19:02:10.450 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverB.mydomain.tld 6379
CONFIG GET slaveof
"serverB.mydomain.tld"
(现在这是错的!)"serverA.mydomain.tld"
(现在这是错的!)另外,这部分每5秒重复一次(无休止地):
[19569] 17 Sep 19:05:40.351 # +redirect-to-master serverA serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:05:40.351 # +redirect-to-master serverB serverB.mydomain.tld 6379 serverA.mydomain.tld 6379
[19569] 17 Sep 19:05:40.723 - Accepted serverB.mydomain.tld:38423
[19569] 17 Sep 19:05:40.724 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:05:40.724 - Accepted serverB.mydomain.tld:38424
[19569] 17 Sep 19:05:40.724 * +sentinel sentinel serverB.mydomain.tld:26379 serverB.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
[19569] 17 Sep 19:05:41.514 - Client closed connection
[19569] 17 Sep 19:05:41.515 - Client closed connection
[19569] 17 Sep 19:05:42.112 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverA serverA.mydomain.tld 6379
[19569] 17 Sep 19:05:42.112 * +sentinel sentinel serverC.mydomain.tld:26379 serverC.mydomain.tld 26379 @ serverB serverA.mydomain.tld 6379
答案 0 :(得分:2)
您必须在Sentinel配置中仅指定主服务器(仅指定主服务器),因为Sentinel本身应自动发现从服务器。
由于这两者都被认为是你的哨兵配置中的主人,所以它很难受。
我建议您阅读redis-sentinel文档以获取更多信息及其工作原理
答案 1 :(得分:0)
我会按如下方式修改您的测试程序(添加粗线):
如果您专门尝试测试堕落案例,请务必忽视我的建议。但是,如果您正在尝试模拟真实的恢复方案,那么粗体线应该告诉哨兵群集了什么。