如何在redis命令行中订阅“+odown”、“+sdown”、“+switch master”?

rbpvctlc  于 2021-06-08  发布在  Redis
关注(0)|答案(1)|浏览(337)

我想让我的redis cli客户端订阅sentinel通知,如“+odown”、“+sdown”、“+switch master”,下面是我尝试的:

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

没有什么。。。我触发了一个故障转移,还是什么都没有。
为了确保我的连接良好,我试着 psubscribe * 触发了另一个故障转移,我只看到一堆:

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"

如何订阅这些内部系统事件?

mrphzbgm

mrphzbgm1#

sentinelEvent(REDIS_WARNING,"+sdown",ri,"%@");

将事件发布到+sdown频道。
在redis sentinel示例上执行。

$ 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"

相关问题