ROLE
Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master
, slave
, or sentinel
. The command also returns additional information about the state of the replication (if the role is master or slave) or the list of monitored master names (if the role is sentinel).
The command returns an array of elements. The first element is the role of the instance, as one of the following three strings:
The additional elements of the array depends on the role.
An example of output when ROLE is called in a master instance:
1) "master" 2) (integer) 3129659 3) 1) 1) "127.0.0.1" 2) "9001" 3) "3129242" 2) 1) "127.0.0.1" 2) "9002" 3) "3129543"
The master output is composed of the following parts:
master
.An example of output when ROLE is called in a slave instance:
1) "slave" 2) "127.0.0.1" 3) (integer) 9000 4) "connected" 5) (integer) 3167038
The slave output is composed of the following parts:
slave
.connect
(the instance needs to connect to its master), connecting
(the slave-master connection is in progress), sync
(the master and slave are trying to perform the synchronization), connected
(the slave is online).An example of Sentinel output:
1) "sentinel" 2) 1) "resque-master" 2) "html-fragments-master" 3) "stats-master" 4) "metadata-master"
The sentinel output is composed of the following parts:
sentinel
.Array reply: where the first element is one of master
, slave
, sentinel
and the additional elements are role-specific as illustrated above.
1) "master"
2) (integer) 0
3) (empty list or set)
© 2009–2017 Salvatore Sanfilippo
Licensed under the Creative Commons Attribution-ShareAlike License 4.0.
https://redis.io/commands/role