Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know master/slave status of redis?

Tags:

redis

How to know status of redis from command line (redis-cli) ? master/slave

like image 646
Bdfy Avatar asked Jul 03 '12 08:07

Bdfy


People also ask

How do I know if Redis Sentinel is running?

You can also use monitor to see what Sentinel is doing: $ redis-cli -p 6379 monitor OK 1546981642.808843 [0 127.0. 0.1:54765] "PING" 1546981642.866671 [0 127.0. 0.1:54765] "PUBLISH" "__sentinel__:hello" "127.0.

Is Master down after milliseconds?

The quorum was set to the value of 2 (last argument of sentinel monitor configuration directive). The down-after-milliseconds value is 5000 milliseconds, that is 5 seconds, so masters will be detected as failing as soon as we don't receive any reply from our pings within this amount of time.


1 Answers

The INFO command returns the current role.

e.g/ if we're the master

role:master 

will be shown, amongst other details.

And if we switch to a slave, maybe by using slaveof:

slaveof 192.168.1.66 6379 

We get more, when we run INFO:

role:slave master_host:192.168.1.66 master_port:6379 master_link_status:down master_last_io_seconds_ago:-1 master_sync_in_progress:0 master_link_down_since_seconds:1341313174 

EDIT: Here's a succinct cli command as shown by Linus (but who's just deleted his post):

redis-cli info | grep ^role 

:)

like image 67
gef Avatar answered Sep 28 '22 15:09

gef