Get redis master sentinels

14.6k views Asked by At

I am trying to get a list of all sentinels which are currently monitoring the redis master.

I know that if I have one sentinel I can use sentinel sentinels mymaster but if I don't have any of the Sentinel's addresses how can I get them?

2

There are 2 answers

1
cagatay On BEST ANSWER

There is no direct command to get the list of sentinels from a master/slave node. To get the sentinels' list, you need to subscribe to any node's pub/sub (master or slave doesn't matter) "__sentinel__:hello" channel and wait for the messages. Messages passing through that hello channel are from sentinels that are listening that cluster. If you parse those, you get the sentinels' addresses. The messages are in form: "sentinel_ip,sentinel_port,sentinel_runid,sentinel_current_epoch,master_name,master_ip,master_port,master_config_epoch" (e.g. 127.0.0.1,26380,07fabf3cbac43bcc955588b1023f95498b58f8f2,16,mymaster,127.0.0.1,6381,16). See: https://redis.io/topics/sentinel#sentinels-and-slaves-auto-discovery about sentinel details. If you need more to know about how sentinel works, take a look at https://github.com/antirez/redis/blob/unstable/src/server.c

0
Iman On

In order to explore more about this instance, you may want to try the following two commands:

SENTINEL slaves mymaster
SENTINEL sentinels mymaster

https://redis.io/topics/sentinel#asking-sentinel-about-the-state-of-a-master