【问题标题】:Redis fail over with sentinel not workingRedis 故障转移,哨兵不工作
【发布时间】:2015-08-14 06:57:11
【问题描述】:

我正在尝试为故障转移支持设置 redis-sentinel 配置。这是我的配置,

machine1 : IP : 10.0.0.1 6379 with redis-sentinel port 26379         
machine2 : IP : 10.0.0.2 6379 with redis-sentinel port 26379     
machine3 : IP : 10.0.0.3 6379 with redis-sentinel port 26379     

Redis 哨兵配置

机器 1:

sentinel monitor mymaster 10.0.0.1 6379 2    
sentinel down-after-milliseconds mymaster 60000    
sentinel failover-timeout mymaster 180000    
sentinel parallel-syncs mymaster 1 

机器 2:

sentinel monitor mymaster 10.0.0.1 6379 2    
sentinel down-after-milliseconds mymaster 60000    
sentinel failover-timeout mymaster 180000    
sentinel parallel-syncs mymaster 1

机器 3:

sentinel monitor mymaster 10.0.0.1 6379 2    
sentinel down-after-milliseconds mymaster 60000    
sentinel failover-timeout mymaster 180000    
sentinel parallel-syncs mymaster 1

添加机器 2 和机器 3 作为机器 1 的从机。复制工作正常。但是当机器 1 关闭时,其他机器不会发生主切换。他们仍然充当奴隶。我的设置有任何配置问题吗?

【问题讨论】:

    标签: amazon-ec2 redis sentinel redis-sentinel


    【解决方案1】:

    在我给出更好的答案之前的一些问题:

    1. 是否在 redis 实例上运行身份验证?
    2. sentinel 是否真的检测到了 pod 的拓扑?

    如果上面的sentinel配置都完成了,sentinel还没有真正附加到master上。 Sentinel 重写配置文件以存储发现的拓扑,因此您最初配置它的内容将伴随它发现的内容。特别是,我们也会看到从属条目。

    另一种可能性是达到法定人数的足够多的哨兵没有成功连接到主节点。如果 Redis 配置了需要身份验证,您还需要使用 sentinel set 命令告诉哨兵身份验证令牌。

    如果您可以发布完整的配置,以及当您关闭 master 时的哨兵日志,我们可以提供更具体的操作。

    在相关说明中,在生产中,我建议不要使用这种设置。有了你拥有的那个,你可以结束所谓的裂脑。如果 master 所在的机器与其他机器隔离,但仍在运行,那么另外两个将选举一个新的 master,此时您将拥有两个 master。如果客户端仍然能够连接到 master,现有连接将保留在原始连接上,但使用 sentinel 获取 master 的新连接将连接到第二个 master。

    通过在不同的机器上运行哨兵可以降低这种风险。如果您的客户端机器数量有限并且可以在那里运行 sentinel,您可以几乎或完全消除这种可能性。

    【讨论】:

    • 谢谢。未在哨兵配置文件中正确添加身份验证。感谢您提出防止脑裂问题的建议。
    猜你喜欢
    • 2021-02-27
    • 2018-07-12
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 2016-02-04
    相关资源
    最近更新 更多