【发布时间】:2016-02-12 12:19:00
【问题描述】:
已经安装了一个 redis (v. 3.0.4) 主从模型,使用 3 个节点(1 个主节点和 2 个从节点),每个节点的 requirepass 如https://www.digitalocean.com/community/tutorials/how-to-configure-a-redis-cluster-on-ubuntu-14-04 所述,然后在每个节点上启动 3 个哨兵,如文章http://blog.commando.io/redis-is-easy-trivial-hard/
在尝试打倒主人后,哨兵如预期将其中一名奴隶提升为主人。然后当老主人起来的时候 它再次成为奴隶并认出了新主人,这可以在 /etc/redis/sentinel.conf 使用新的主 IP 更新 在 'sentinel monitor redis-cluster' 属性中。 但是已经注意到旧的master尽管知道新的master IP,但它认为新的master是down的,不像其他slave看到它。这可以通过对旧主服务器运行此命令来检查:
$redis-cli -a altoros info replication
#
Replication
role:slave
master_host: new master ip
master_port:6379
master_link_status:down
当尝试使用同步客户端测试节点上的数据复制时,这似乎也导致了以下错误“与 MASTER 的 MASTERDOWN 链接已关闭并且 slave-serve-stale-data 设置为 'no'”。
The logs of the old masters (/var/log/redis/redis-server.log) are showing:
20731:S 09 Nov 10:16:31.117 * Connecting to MASTER <new master="" ip="">: 6379
20731:S 09 Nov 10:16:31.117 * MASTER <-> SLAVE sync started
20731:S 09 Nov 10:16:31.118 * Non blocking connect for SYNC fired the event.
20731:S 09 Nov 10:16:31.118 * Master replied to PING, replication can continue...
20731:S 09 Nov 10:16:31.119 * (Non critical) Master does not under stand REPLCONF listening-port: -NOAUTH Authentication required.
20731:S 09 Nov 10:16:31.119 * (Non critical) Master does not under stand REPLCONF capa:
-NOAUTH Authentication required.
这看起来旧的 master 无法向新的 master 进行身份验证,因为它 没有他的密码,但是如何正确设置呢?
因为已经注意到 /etc/redis/redis.conf 并没有在新的 master 被更改后更改 提升,不像/etc/redis/sentinel.conf,这可能会导致主服务器的redis.conf没有新主服务器的密码。
希望能提供任何解决问题的提示,在此先感谢。
【问题讨论】:
-
你说你在每个节点上都设置了
requirepass,并且你必须设置masterauth才能让slave正常工作,但是你是否也在哨兵中设置了sentinel auth-pass配置? -
是的
sentinel auth-pass在 sentinel 配置文件 (/etc/redis/sentinel.conf) 中设置,否则当初始 master 被删除时,sentinel 无法将其中一个 slave 提升为 master。所以问题似乎不在哨兵级别,而是在redis级别。
标签: redis redis-sentinel