Tom*_*mir 5 redis redis-sentinel
我正在尝试获取当前正在监视 redis master 的所有哨兵的列表。
我知道如果我有一个哨兵,我就可以使用sentinel sentinels mymaster,但如果我没有任何哨兵的地址,我怎样才能获得它们?
没有直接命令可以从主/从节点获取哨兵列表。要获取哨兵列表,您需要订阅任何节点的 pub/sub(主节点或从节点无关)的“__sentinel__:hello”频道并等待消息。通过该 hello 通道的消息来自正在侦听该集群的哨兵。如果你解析这些,你就会得到哨兵的地址。消息的格式为:“sentinel_ip,sentinel_port,sentinel_runid,sentinel_current_epoch,master_name,master_ip,master_port,master_config_epoch”(例如 127.0.0.1,26380,07fabf3cbac43bcc955588b1023f95498b58f8f2,16,mymaster,127.0.0。 1,6381,16)。有关哨兵详细信息,请参阅: https: //redis.io/topics/sentinel#sentinels-and-slaves-auto-discovery 。如果您需要更多了解哨兵的工作原理,请查看https://github.com/antirez/redis/blob/unstable/src/server.c