- Reference >
- Database Commands >
- Replication Commands >
- replSetGetStatus
replSetGetStatus¶
On this page
Definition¶
-
replSetGetStatus
¶ The
replSetGetStatus
command returns the status of the replica set from the point of view of the current server. You must run the command against the admin database. The command has the following prototype format:The value specified does not affect the output of the command. Data provided by this command derives from data included in heartbeats sent to the current instance by other members of the replica set. Because of the frequency of heartbeats, these data can be several seconds out of date.
You can also access this functionality through the
rs.status()
helper in themongo
shell.The
mongod
must have replication enabled and be a member of a replica set for the forreplSetGetStatus
to return successfully.
Example¶
The following example runs the replSetGetStatus command on the admin database of the replica set primary:
Consider the following example output:
Output¶
The replSetGetStatus command returns a document with the following fields:
-
replSetGetStatus.
set
¶ The
set
value is the name of the replica set, configured in thereplSetName
setting. This is the same value as_id
inrs.conf()
.
-
replSetGetStatus.
date
¶ The value of the
date
field is an ISODate of the current time, according to the current server. Compare this to the value of thelastHeartbeat
to find the operational lag between the current host and the other hosts in the set.
-
replSetGetStatus.
myState
¶ The value of
myState
is an integer between0
and10
that represents the replica state of the current member.
-
replSetGetStatus.
members
¶ The
members
field holds an array that contains a document for every member in the replica set.-
replSetGetStatus.members[n].
name
¶ The
name
field holds the name of the server.
-
replSetGetStatus.members[n].
self
¶ The
self
field is only included in the document for the currentmongod
instance in the members array. It’s value istrue
.
-
replSetGetStatus.members[n].
health
¶ The
health
value is only present for the other members of the replica set (i.e. not the member that returnsrs.status
.) This field conveys if the member is up (i.e.1
) or down (i.e.0
.)
-
replSetGetStatus.members.
state
¶ The value of
state
is an integer between0
and10
that represents the replica state of the member.
-
replSetGetStatus.members[n].
stateStr
¶ A string that describes
state
.
-
replSetGetStatus.members[n].
uptime
¶ The
uptime
field holds a value that reflects the number of seconds that this member has been online.This value does not appear for the member that returns the
rs.status()
data.
-
replSetGetStatus.members[n].
optime
¶ Information regarding the last operation from the operation log that this member has applied.
-
replSetGetStatus.members[n].optime.
t
¶ A 32-bit timestamp of the last operation applied to this member of the replica set from the oplog.
-
replSetGetStatus.members[n].optime.
i
¶ An incremented field, which reflects the number of operations in since the last time stamp. This value only increases if there is more than one operation per second.
-
-
replSetGetStatus.members[n].
optimeDate
¶ An ISODate formatted date string that reflects the last entry from the oplog that this member applied. If this differs significantly from
lastHeartbeat
this member is either experiencing “replication lag” or there have not been any new operations since the last update. Comparemembers.optimeDate
between all of the members of the set.
-
replSetGetStatus.members[n].
electionTime
¶ For the current primary, information regarding the election time from the operation log. See Replica Set Elections for more information about elections.
-
replSetGetStatus.members[n].electionTime.
t
¶ For the current primary, a 32-bit timestamp of the election time applied to this member of the replica set from the oplog.
-
replSetGetStatus.members[n].electionTime.
i
¶ For the current primary, an incremented field which reflects the number of operations in since the last time stamp. This value only increases if there is more than one operation per second.
-
-
replSetGetStatus.members[n].
electionDate
¶ For the current primary, an ISODate formatted date string that reflects the election date. See Replica Set Elections for more information about elections.
-
replSetGetStatus.members[n].
self
¶ Indicates which replica set member processed the replSetGetStatus command.
-
replSetGetStatus.members[n].
lastHeartbeat
¶ The
lastHeartbeat
value provides an ISODate formatted date and time of the transmission time of last heartbeat received from this member. Compare this value to the value of thedate
andlastHeartBeatRecv
field to track latency between these members.This value does not appear for the member that returns the
rs.status()
data.
-
replSetGetStatus.members[n].
lastHeartbeatRecv
¶ The
lastHeartbeatRecv
value provides an ISODate formatted date and time that the last heartbeat was received from this member. Compare this value to the value of thedate
andlastHeartBeat
field to track latency between these members.
-
replSetGetStatus.members[n].
lastHeartbeatMessage
¶ When the last heartbeat included an extra message, the
lastHeartbeatMessage
contains a string representation of that message.
-
replSetGetStatus.members[n].
pingMs
¶ The
pingMs
represents the number of milliseconds (ms) that a round-trip packet takes to travel between the remote member and the local instance.This value does not appear for the member that returns the
rs.status()
data.
-
replSetGetStatus.members[n].
syncingTo
¶ The
syncingTo
field is only present on the output ofrs.status()
on secondary and recovering members, and holds the hostname of the member from which this instance is syncing.
-
replSetGetStatus.members[n].
configVersion
¶ New in version 3.0.
The
configVersion
value is thereplica set configuration version
.
-