Distributed design - Sentinel

  • effect
    • Redis server monitoring operational status can be automatic failover (failover), high availability
    • Mechanism with the database used by the owner from the mating
  • Feature
    • Separate processes, each redis server should have at least one sentinel program
    • Status Monitoring redis primary server
    • You can notify the administrator / other programs after a failure
    • For fault can be automatically transferred, and to provide new access address of the client

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  • Rumors agreement
    • When a ping program found Sentinel monitors the primary server offline (heartbeat), will be asked to monitor the other Sentinel server, the primary server to confirm whether or offline, when the number of sentinel confirmed to meet the requirements (profile set) after , confirms that the primary server offline (objective offline), and then enter the voting session
  • Voting Agreement
    • After confirming the primary objective offline server, which guards will be authorized to vote by way of a sentry leading failover process
    • Only under the premise of most of Sentinel are to vote, it will be authorized, for example, there are five guards, you need at least 3 Sentry may vote only authorized
    • The purpose is to avoid false failure migration occurs
  • Recommended minimum configuration
    • Each start sentinel at least on the at least one server 3
    • If only one, then the server goes down, will not fail to migrate
    • If only two, once a sentry hung up, then the vote will fail
  • Configuration (sentinel.conf)
    bind 127.0.0.1  # 哨兵绑定的ip
    port 26381  # 哨兵监听的端口号, redis客户端需要访问哨兵的ip和端口号
    sentinel monitor mymaster 127.0.0.1 6380 2  # 设置哨兵  (主数据库别名 主数据库ip 主数据库端口 确认下线的最小哨兵数量)
    
    sentinel down-after-milliseconds mymaster 60000  # 服务器断线超时时长
    sentinel failover-timeout mymaster 180000  # 故障转移的超时时间
    sentinel parallel-syncs mymaster 1  # 执行故障转移时,最多几个从数据库可以同时同步主数据库数据(数量少会增加完成转移的时长; 数量多则正在同步的从数据库会因同步而无法提供数据查询功能)
  • Start Sentinel
    sudo redis-sentinel sentinel.conf
  • python accessed by redis Sentinel
    • redis-py in function to integrate Sentinel

mysql official did not provide failover scenarios, we need to use third-party services, such as keepalive, etc.

Guess you like

Origin www.cnblogs.com/oklizz/p/11414376.html