Warm tip: This article is reproduced from serverfault.com, please click

How to subscribe to "+odown", "+sdown", "+switch-master" in Redis command line?

发布于 2020-09-08 07:42:53

I want my redis-cli client to subscribe to sentinel notifications like "+odown", "+sdown", "+switch-master", here is what i tried:

$ redis-cli
127.0.0.1:6379> subscribe "+odown"

nothing... I triggered a failover, still nothing.

To make sure my connection is good, I tried psubscribe * and triggered another failover, I only see a bunch of:

3) "__sentinel__:hello"
4) "127.0.0.1,5001,ece169c208d80543b07a18ead87c53eb4bd87e4a,30,mymaster,127.0.0.1,6380,30"
1) "pmessage"
2) "*"
3) "__sentinel__:hello"
4) "127.0.0.1,5001,ece169c208d80543b07a18ead87c53eb4bd87e4a,30,mymaster,127.0.0.1,6380,30"
1) "pmessage"
2) "*"
3) "__sentinel__:hello"
4) "127.0.0.1,5000,060d95f0255ca3a70fa33b5caa5dbba787c3af55,30,mymaster,127.0.0.1,6380,30"

What can I do to subscribe to those internal system events?

Questioner
return 0
Viewed
0
shuffle x 2020-11-29 21:32:22
sentinelEvent(REDIS_WARNING,"+sdown",ri,"%@");

will pub events to +sdown channel.

Do it on a redis sentinel instance.

$ ps -ef | grep redis  
root      13961      1  0 21:30 ?        00:00:00 redis-server *:26379 [sentinel]

$ redis-cli -p 26379  
127.0.0.1:26379> subscribe +sdown
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "+sdown"
3) (integer) 1
1) "message"
2) "+sdown"
3) "master mymaster 127.0.0.1 6379"