【问题标题】:Redis node won't go into MASTER modeRedis 节点不会进入 MASTER 模式
【发布时间】:2019-10-31 06:31:03
【问题描述】:

我有一个简单的 redis 部署 MASTER、SLAVE 和 2 SENTINEL 在 docker swarm 上运行。我运行堆栈,所有服务都出现了。 redis-master 以 MASTER 启动,我将其杀死以测试 SENTINEL 和 SLAVE 恢复。 redis-master 然后恢复并成为一个新的 SLAVE。如果我 ecex 进入它并运行 SLAVEOF NO ONE,则会发生以下情况:

1:M 31 Oct 2019 06:28:32.741 * MASTER MODE enabled (user request from 'id=3907 addr=127.0.0.1:39302 fd=36 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=34 qbuf-free=32734 obl=0 oll=0 omem=0 events=r cmd=slaveof')
1:S 31 Oct 2019 06:28:43.060 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
1:S 31 Oct 2019 06:28:43.060 * REPLICAOF 10.0.21.49:6379 enabled (user request from 'id=1085 addr=10.0.21.54:34360 fd=16 name=sentinel-592f3b97-cmd age=945 idle=0 flags=x db=0 sub=0 psub=0 multi=3 qbuf=150 qbuf-free=32618 obl=36 oll=0 omem=0 events=r cmd=exec')
1:S 31 Oct 2019 06:28:43.701 * Connecting to MASTER 10.0.21.49:6379
1:S 31 Oct 2019 06:28:43.702 * MASTER <-> REPLICA sync started
1:S 31 Oct 2019 06:28:43.702 * Non blocking connect for SYNC fired the event.
1:S 31 Oct 2019 06:28:43.702 * Master replied to PING, replication can continue...
1:S 31 Oct 2019 06:28:43.703 * Trying a partial resynchronization (request a056665afb95a1e3a4227ae7fcb1c9b2e2f3b222:244418).
1:S 31 Oct 2019 06:28:43.703 * Full resync from master: adde2c9daee4fa1e62d3494d74d08dfb7110c798:241829
1:S 31 Oct 2019 06:28:43.703 * Discarding previously cached master state.
1:S 31 Oct 2019 06:28:43.715 * MASTER <-> REPLICA sync: receiving 2229 bytes from master
1:S 31 Oct 2019 06:28:43.715 * MASTER <-> REPLICA sync: Flushing old data
1:S 31 Oct 2019 06:28:43.715 * MASTER <-> REPLICA sync: Loading DB in memory
1:S 31 Oct 2019 06:28:43.715 * MASTER <-> REPLICA sync: Finished with success

主模式启动,但随后被 REPLICAOF 接管!如何强制 redis-master 始终是 MASTER?

【问题讨论】:

    标签: redis redis-cli


    【解决方案1】:

    是的,我认为这是有道理的。

    哨兵会永远记住谁加入了主从组。

    当您手动设置当前从属主机时,哨兵不知道您是否故意这样做,或者发生了网络部分。所以哨兵会做一个convert-to-slave来避免两个master存在于一个组中。 (又名split-brain

    从组中删除一个节点

    检查docs,简而言之,你需要将SENTINEL RESET mastername发送给所有哨兵,让他们忘记丢失的节点。然后将丢失的节点作为master启动,它不会加入sentinel的组。

    使前一个(失败的)主节点保持为主节点。

    在丢失的master作为slave回来后,你可以做一个SENTINEL failover &lt;master name&gt;,sentinels会做一个failover并切换master和slave。但是我觉得超过3个节点就不能指定master了。

    【讨论】:

    • 好的!暂时保持这种状态。也许我们会得到另一个答案:-)
    猜你喜欢
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-18
    • 2017-06-23
    • 2019-09-10
    • 1970-01-01
    • 2018-07-09
    相关资源
    最近更新 更多