zoukankan      html  css  js  c++  java
  • Redis为什么不能使用一主一从哨兵

    哨兵机制

    识别挂掉的主节点

    quorum(法定人数)
    是判定主节点不能访问所需要的最少哨兵数量

    执行失效备援perform a failover

    其中一个哨兵需要被选为救援的领导,并被授权执行救援,而这需要过半数的哨兵同意

    So for example if you have 5 Sentinel processes, and the quorum for a given master set to the value of 2, this is what happens:

    • If two Sentinels agree at the same time about the master being unreachable, one of the two will try to start a failover.
    • If there are at least a total of three Sentinels reachable, the failover will be authorized and will actually start.

    In practical terms this means during failures Sentinel never starts a failover if the majority of Sentinel processes are unable to talk (aka no failover in the minority partition).

    一主一从哨兵

    +----+         +----+

    | M1 |-------| R1 |

    | S1 |         | S2 |

    +----+         +----+

    Configuration: quorum = 1

     

    如果M1挂掉,R1会成为主节点,因为两个哨兵可以就M1的失效达成一致,而且可以授权救援。表面上这样可以工作,但是请看下面这种情况。

    如果M1所在的机器直接停掉,同时S1就停止工作。这样的话S2就不能授权救援,整个系统就不可用了。

    要注意的是,失效救援是需要过半数的哨兵同意。同时如果上图只在一边执行救援,并且没有授权,会非常危险:

    +----+           +------+

    | M1 |----//-----| [M1] |

    | S1 |           | S2   |

    +----+           +------+

    上面的配置了两个主节点(完美对称)(假设S2可以没有授权进行救援)。

    客户端可能无限期地往两边写入数据,当网络恢复时并不能知道哪边的配置是对的。

    所以至少请在配置三个哨兵在三个不同的机器上。

  • 相关阅读:
    防止域名恶意指向的解决办法
    Spring @Configuration @Import
    CAS 集成认证
    远程桌面登录蓝色屏幕、不显示桌面怎么解决?
    终端服务器超出了最大允许连接数
    Fiddler 常见几种解决捕获不到请求的方法
    android TimerTask 的简单应用
    Android 数字签名学习笔记
    Android 遍历卡数据并按图片,音乐等分类保存
    Android 最简单的SD卡文件遍历程序
  • 原文地址:https://www.cnblogs.com/jugglee/p/8671723.html
Copyright © 2011-2022 走看看