问题描述
我有一个 redis 主设置,其中有 2 个从站和一个哨兵.
I have a redis master setup with 2 slaves and a sentinal on each.
如果 master 宕机 2 秒(+sdown)然后恢复(-sdown),它读取最后一个快照,slave 与 master 重新同步.
If the master goes down for say 2 seconds (+sdown) and comes back up (-sdown), it reads the last snapshot, and the slaves resync with the master.
这样做的问题是在上次保存和 +sdown 之间可能有很多写入.似乎如果主从 +sdown 到 -sdown 并且从不 +odown(启动故障转移),它应该能够从从同步.我的推理是复制流是连续的,当 +sdown 发生时,从服务器很可能对主服务器的状态有更准确的反映.
The problem with this is that there may have been many writes between the last save and the +sdown. It seems like if the master goes from +sdown to -sdown and never +odown (where a failover is initiated), it should be able to sync FROM a slave. My reasoning is that the replication stream is continuous and the slaves most likely have a more accurate reflection of the masters state when +sdown happened.
有什么配置可以做到这一点吗?我是否被迫依赖 AOF 或快照?
Is there some config that I can do this? Am I forced to rely on the AOF or snapshots?
(添加哨兵标签)
推荐答案
你不能做部分故障转移,无论是做还是不做,都可以将奴隶升级为主人.
You cannot do a partial failover, either you do it or you don't in terms of promoting the slave to master.
来自 Redis 哨兵:
自动故障转移.如果 master 没有按预期工作,Sentinel 可以启动一个故障转移过程,其中一个 slave 被提升为 master,其他额外的 slave 被重新配置为使用新的 master,并且使用 Redis 服务器的应用程序被告知要使用的新地址.连接.
这篇关于Redis 复制配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!