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
🙂