Redis:故障切换失败 – 哨兵不能select新的主节点

我已经在一个简单的主从设置中的四个不同的虚拟机上设置了四个服务器哨兵实例。 密钥复制工作正常,所有redis节点相互识别(我指的是known-sentinelknown-slave选项)。

当我试图模拟失败时出现问题。 哨兵只是不断地告诉他们不能选举一个新的主人( 故障转移 – 中止 – 不是选举 ):

 12481:X 22 Jun 17:20:05.761 # <__IP1__>:51002 voted for a3ba8d8cd0c15c8b186b44ba529b83d3a8424a42 27 12481:X 22 Jun 17:20:14.140 # -sdown master mymaster <__IP2__> 6379 12481:X 22 Jun 17:20:14.140 # -odown master mymaster <__IP2__> 6379 12481:X 22 Jun 17:20:16.567 # -failover-abort-not-elected master mymaster <__IP2__> 6379 

另一个奇怪的事情是,当我在redis-cli查询标记的状态时,我得到的可用标记实例的数量比实际计数要大(当然,不能大于4(正确?))。

 $ redis-cli -p 51001 > info [...] master0:name=mymaster,status=ok,address=91.120.59.231:6379,slaves=3,sentinels=8 

另外,当启动sentinel的时候,我总是收到这些-dup-sentinel消息:

 14563:X 23 Jun 11:10:18.015 * -dup-sentinel master mymaster <__IP_MASTER__> 6379 #duplicate of <__IP_SLAVE2__>:51003 or 65db9ddba84433f71aa77c9263807e6abd939d2c 

这是一个哨兵的configuration:

 daemonize yes pidfile "/var/run/redis/redis-sentinel.pid" logfile "/var/log/redis/redis-sentinel.log" # bind 192.168.1.100 10.0.0.1 # port 26379 port 51004 dir "/var/lib/redis" sentinel monitor mymaster <__IP_MASTER__> 6379 2 sentinel failover-timeout mymaster 60000 sentinel auth-pass mymaster <___________PASSW___________> sentinel config-epoch mymaster 0 sentinel leader-epoch mymaster 55428 # Generated by CONFIG REWRITE maxclients 4064 sentinel known-slave mymaster <__IP_SLAVE1__> 6379 sentinel known-slave mymaster <__IP_SLAVE2__> 6379 sentinel known-slave mymaster <__IP_SLAVE3__> 6379 sentinel known-sentinel mymaster <__IP_SLAVE1__> 51002 bfea8e89873353d5c1e9ed498b17f298bd6b6082 sentinel known-sentinel mymaster <__IP_MASTER__> 26379 c04fc07022a251e56e81e21dbe018bd471745038 sentinel known-sentinel mymaster <__IP_SLAVE2__> 51003 b5a56eb69abb5893203ecf7b1a7d28ae4aa06ab5 sentinel known-sentinel mymaster <__IP_MASTER__> 51001 be1ff6c9e4a62abea132c24447fd3cb38d221496 sentinel known-sentinel mymaster <__IP_SLAVE1__> 26379 f5a7fd0ee199afc02ffafc0e822363acf5595b1c sentinel known-sentinel mymaster <__IP_SLAVE2__> 26379 6328962293b7838fa88b9f176b9bc4cc08f2e26d sentinel current-epoch 26 

日志文件是不是真的有用的信息…有没有办法让它更详细一点? 你有什么想法我在这里误解?

提前致谢!

撞柱:

检查了防火墙设置,应该没问题,但是当我完全closures防火墙时,仍然遇到同样的错误。

采取定点默认configuration :

 # *** IMPORTANT *** # # By default Sentinel will not be reachable from interfaces different than # localhost, either use the 'bind' directive to bind to a list of network # interfaces, or disable protected mode with "protected-mode no" by # adding it to this configuration file. # # Before doing that MAKE SURE the instance is protected from the outside # world via firewalling or other means. # # For example you may use one of the following: # # bind 127.0.0.1 192.168.1.1 

所以尝试绑定你的server's IP

格鲁克!

旧的哨兵不会从configuration中删除。 看文档redis sentinel

执行: SENTINEL RESET mymaster ,一会儿,新的主人应该被选上。