Redis节点将不会进入MASTER模式

时间:2019-10-31 06:31:03

标签: redis redis-cli

我在docker swarm上运行了一个简单的redis部署MASTER,SLAVE和2 SENTINEL。我运行堆栈,然后出现所有服务。 redis-master以MASTER身份启动,我将其杀死以测试SENTINEL和SLAVE恢复。然后,redis-master恢复并成为新的SLAVE。如果我加入其中并运行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?

1 个答案:

答案 0 :(得分:0)

是的,我认为这很有意义。

Sentinel永远记住谁加入了主从组。

当您手动制作当前从属主机时,哨兵不知道您是故意这样做的,还是发生了网络部分。因此,哨兵将执行convert-to-slave以避免组中存在两个母版。 (又名split-brain

要将节点从组中删除

检查docs,简而言之,您需要将SENTINEL RESET mastername发送给所有哨兵,以使他们忘记丢失的节点。然后将丢失的节点作为主节点启动,它将不会加入前哨的团队。

要使先前的(发生故障的)主节点保持为主节点状态。

丢失的主服务器重新成为从服务器后,您可以执行SENTINEL failover <master name>,哨兵将执行故障转移并切换主服务器和从服务器。但是当节点数超过3个时,我认为您不能任命一个主机。