Tomer Amir
Tomer Amir

Reputation: 1595

Get redis master sentinels

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?

Upvotes: 5

Views: 20417

Answers (2)

Iman
Iman

Reputation: 18966

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

Upvotes: 2

cagatay
cagatay

Reputation: 514

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

Upvotes: 4

Related Questions