Redis Sentinel

Redis Sentinel

What is Redis Sentinel?

Redis Sentinel is the high availability solution of Redis. It provides this by providing 3 things:

  • Monitoring
  • Automatic failover
  • Configuration provider

Redis Sentinel will monitor and automatically detect a master failure and bring all clusters to a stable mode. This makes sure that human interaction will not be needed in case of a fail.

Sentinel decides if the master went down or not. If it is not reachable, Sentinel will choose a replica, which are exact copies of the master, and promote it until the master comes back.

Fundamentals of Sentinel

Sentinel documentation states that at least three sentinel instances are required for robust deployment. Although they can run as parallel processes in the same Redis instance, they should be placed into servers or VMs that are believed to fail independently.

Sentinel constantly checks the master for a failure. If enough sentinel agrees that the master is down then it acts as an authority and will start a failover process. As a result, it will promote a replica to be the master, configure other replicas to use new master until the master node is reachable again.

Sentinel agreement depends on the quorum value. Quorum value is the minimum number of the sentinels agree that the master is not reachable now. For 3 sentinel instances, the usual quorum value is 2.

Redis Sentinel

What will this mean for my applications? It means that they will connect to sentinel and sentinel instances will provide the latest master node.

  1. 核心功能

    • 高可用解决方案:Redis Sentinel为Redis提供监控、自动故障转移和配置管理功能,确保集群稳定运行。
    • 监控:持续检测主节点(master)和副本节点(replica)的健康状态。
    • 自动故障转移:主节点故障时,自动选举并提升副本节点为新主节点。
    • 配置提供:作为客户端连接的配置中心,对外提供最新的主节点地址。
  2. 部署要求

    • 最少3个Sentinel实例:需部署在独立的服务器或虚拟机中,避免单点故障影响整体判断。
    • 独立故障域:实例应分布在不同的物理/逻辑环境中,确保能独立检测故障。
  3. 故障检测与决策

    • 主观/客观下线:单个Sentinel判定主节点不可达(主观下线),需多数Sentinel同意(客观下线)才会触发故障转移。
    • 仲裁机制(Quorum):需至少指定数量的Sentinel(如3个实例中设quorum=2)确认主节点故障,以启动故障转移流程。
  4. 故障转移流程

    • 选举新主节点:从可用副本中选择数据最新的节点作为新主节点。
    • 自动重配置:更新其他副本指向新主节点,原主节点恢复后降级为副本。
  5. 对应用的影响

    • 透明切换:应用程序通过连接Sentinel获取当前主节点地址,无需硬编码配置,故障切换对应用透明。
  6. 设计目标

    • 减少人工干预:通过自动化实现快速故障恢复,避免人工操作延迟或错误。
    • 高可靠性:通过分布式Sentinel实例和多数决策机制降低误判风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值