检查 Sentinel 状态、当前主节点和法定人数
RedisSentinel命令
redis-cli -p 26379 SENTINEL MASTERS
redis-cli -p 26379 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
redis-cli -p 26379 SENTINEL REPLICAS mymaster
redis-cli -p 26379 SENTINEL SENTINELS mymaster
# Are there enough sentinels (quorum and majority) for a failover:
redis-cli -p 26379 SENTINEL CKQUORUM mymaster
redis-cli -p 26379 INFO sentinel作用
列出 Sentinel 监控的主节点、当前主节点地址、已知的副本和其他 sentinel;验证故障转移所需的法定人数(quorum)和多数派是否可用。
适用场景
应用连接到错误节点时、故障转移后验证拓扑时,以及每次维护之前。
注意
每个 sentinel 报告的是其自身视角;GET-MASTER-ADDR-BY-NAME 必须在所有 sentinel 上返回相同的地址,否则说明存在网络分区或配置不一致。flags 字段中的 s_down/o_down 或副本上的 disconnected 需要紧急排查。Sentinel 端口(26379)在防火墙中应只对 sentinel 之间以及客户端开放。