Definition
replSetGetStatusThe
replSetGetStatuscommand returns the status of the replica set from the point of view of the server that processed the command.replSetGetStatusmust be run on the admin database.The
mongodinstance must be a replica set member forreplSetGetStatusto return successfully.Data provided by this command derives from data included in heartbeats sent to the server by other members of the replica set. Because of the frequency of heartbeats, these data can be several seconds out of date.
Tip
In
mongosh, this command can also be run through thers.status()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
Compatibility
This command is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Important
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Syntax
The command has the following syntax:
db.adminCommand( { replSetGetStatus: 1 } )
If you run replSetGetStatus or the mongosh helper
rs.status() on a member during its initial sync (i.e. STARTUP2 state), the command
returns replSetGetStatus.initialSyncStatus metrics.
After the member completes the initial synchronization and transitions to
another state, the replSetGetStatus.initialSyncStatus metrics are no
longer available.
Note
If you haven't yet initialized your replica
set, the replSetGetStatus command returns the following error:
MongoServerError: no replset config has been received
Run the replSetInitiate command and try again.
Example
The following example runs the replSetGetStatus
command on the admin database of the replica set
primary:
db.adminCommand( { replSetGetStatus: 1 } )
The command returns the following output for an example replica set primary:
{ "set" : "replset", "date" : ISODate("2024-08-15T23:06:13.978Z"), "myState" : 1, "term" : Long(3), "syncSourceHost" : "", "syncSourceId" : -1, "heartbeatIntervalMillis" : Long(2000), "majorityVoteCount" : 2, "writeMajorityCount" : 2, "votingMembersCount" : 3, "writableVotingMembersCount" : 3, "optimes" : { "lastCommittedOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "lastCommittedWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "readConcernMajorityOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "readConcernMajorityWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "appliedOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "writtenOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "durableOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "lastAppliedWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime" : ISODate("2024-08-15T23:06:13.978Z") }, "lastStableRecoveryTimestamp" : Timestamp(1723763173, 1), "electionCandidateMetrics" : { "lastElectionReason" : "stepUpRequestSkipDryRun", "lastElectionDate" : ISODate("2024-08-15T23:06:13.978Z"), "electionTerm" : Long(3), "lastCommittedOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(2) }, "lastSeenOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(2) }, "lastSeenWrittenOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "numVotesNeeded" : 2, "priorityAtElection" : 1, "electionTimeoutMillis" : Long(10000), "priorPrimaryMemberId" : 1, "numCatchUpOps" : Long(0), "newTermStartDate" : ISODate("2024-08-15T23:06:13.978Z"), "wMajorityWriteAvailabilityDate" : ISODate("2024-08-15T23:06:13.978Z") }, "electionParticipantMetrics" : { "votedForCandidate" : true, "electionTerm" : Long(2), "lastVoteDate" : ISODate("2024-08-15T23:06:13.978Z"), "electionCandidateMemberId" : 1, "voteReason" : "", "lastAppliedOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "lastWrittenOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "maxAppliedOpTimeInSet" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "priorityAtElection" : 1 }, "members" : [ { "_id" : 0, "name" : "m1.example.net:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 269, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "syncSourceHost" : "", "syncSourceId" : -1, "infoMessage" : "", "electionTime" : Timestamp(1723763173, 1), "electionDate" : ISODate("2024-08-15T23:06:13.978Z"), "configVersion" : 1, "configTerm" : 0, "self" : true, "lastHeartbeatMessage" : "" }, { "_id" : 1, "name" : "m2.example.net:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 266, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeDurableDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeat" : ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeatRecv" : ISODate("2024-08-15T23:06:13.978Z"), "pingMs" : Long(0), "lastHeartbeatMessage" : "", "syncSourceHost" : "m3.example.net:27017", "syncSourceId" : 2, "infoMessage" : "", "configVersion" : 1 }, { "_id" : 2, "name" : "m3.example.net:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 266, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeDurableDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeat" : ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeatRecv" : ISODate("2024-08-15T23:06:13.978Z"), "pingMs" : Long(0), "lastHeartbeatMessage" : "", "syncSourceHost" : "m1.example.net:27017", "syncSourceId" : 0, "infoMessage" : "", "configVersion" : 1 } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1723763173, 1), "signature" : { "hash" : BinData(0,"9C2qcGVkipEGJW3iF90qxb/gIwc="), "keyId" : Long("6800589497806356482") } }, "operationTime" : Timestamp(1723763173, 1) }
The following example runs the replSetGetStatus
command on the admin database of the replica set
secondary:
db.adminCommand( { replSetGetStatus: 1 } )
The command returns the following output for an example replica set secondary:
{ "set" : "replset", "date" : ISODate("2024-08-15T23:06:13.978Z"), "myState" : 2, "term" : Long(3), "syncSourceHost" : "m3.example.net:27017", "syncSourceId" : 2, "heartbeatIntervalMillis" : Long(2000), "majorityVoteCount" : 2, "writeMajorityCount" : 2, "votingMembersCount" : 3, "writableVotingMembersCount" : 3, "optimes" : { "lastCommittedOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "lastCommittedWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "readConcernMajorityOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "readConcernMajorityWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "appliedOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "writtenOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "durableOpTime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "lastAppliedWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime" : ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime" : ISODate("2024-08-15T23:06:13.978Z") }, "lastStableRecoveryTimestamp" : Timestamp(1723763173, 1), "electionParticipantMetrics" : { "votedForCandidate" : true, "electionTerm" : Long(3), "lastVoteDate" : ISODate("2024-08-15T23:06:13.978Z"), "electionCandidateMemberId" : 0, "voteReason" : "", "lastAppliedOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(2) }, "lastWrittenOpTimeAtElection" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "maxAppliedOpTimeInSet" : { "ts" : Timestamp(1723763173, 1), "t" : Long(2) }, "maxWrittenOpTimeInSet" : { "ts" : Timestamp(1723763173, 1), "t" : Long(1) }, "priorityAtElection" : 1, "newTermStartDate" : ISODate("2024-08-15T23:06:13.978Z"), "newTermAppliedDate" : ISODate("2024-08-15T23:06:13.978Z") }, "members" : [ { "_id" : 0, "name" : "m1.example.net:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 407, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeDurableDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeat" : ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeatRecv" : ISODate("2024-08-15T23:06:13.978Z"), "pingMs" : Long(0), "lastHeartbeatMessage" : "", "syncSourceHost" : "", "syncSourceId" : -1, "infoMessage" : "", "electionTime" : Timestamp(1723763173, 1), "electionDate" : ISODate("2024-08-15T23:06:13.978Z"), "configVersion" : 1 }, { "_id" : 1, "name" : "m2.example.net:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 409, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "syncSourceHost" : "m3.example.net:27017", "syncSourceId" : 2, "infoMessage" : "", "configVersion" : 1, "configTerm" : 0, "self" : true, "lastHeartbeatMessage" : "" }, { "_id" : 2, "name" : "m3.example.net:27017", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 407, "optime" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeWritten" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDurable" : { "ts" : Timestamp(1723763173, 1), "t" : Long(3) }, "optimeDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeWrittenDate" : ISODate("2024-08-15T23:06:13.978Z"), "optimeDurableDate" : ISODate("2024-08-15T23:06:13.978Z"), "lastAppliedWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastWrittenWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastDurableWallTime": ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeat" : ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeatRecv" : ISODate("2024-08-15T23:06:13.978Z"), "pingMs" : Long(0), "lastHeartbeatMessage" : "", "syncSourceHost" : "m1.example.net:27017", "syncSourceId" : 0, "infoMessage" : "", "configVersion" : 1 } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1723763173, 1), "signature" : { "hash" : BinData(0,"kmhE5YARZlzn/DX4B/D0E5P6okY="), "keyId" : Long("6800589497806356482") } }, "operationTime" : Timestamp(1723763173, 1), }
- In earlier versions (3.6.x-4.2.0)
You can include the optional
initialSync: 1to include thereplSetGetStatus.initialSyncStatusin the output (you can omit if you do not want to return the initial sync status):db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } )
- Starting in MongoDB 5.2,
- the
replSetGetStatus.initialSyncStatusdocument contains additional fields when using a file copy based initial sync.
If you run replSetGetStatus on a member during its
initial sync, the command returns
replSetGetStatus.initialSyncStatus metrics.
db.adminCommand( { replSetGetStatus: 1 } )
After the member completes the initial synchronization and
transitions to another state, the
replSetGetStatus.initialSyncStatus metrics are no
longer available.
The following example runs the replSetGetStatus
command on the admin database of the 4.4 replica
set member during its initial sync:
{ "set" : "replset", "date" : ISODate("2024-08-15T23:06:13.978Z") "myState" : 5, "term" : Long(1), "syncSourceHost" : "m1.example.net:27017", "syncSourceId" : 0, "heartbeatIntervalMillis" : Long(2000), "majorityVoteCount" : 2, "writeMajorityCount" : 2, "votingMembersCount" : 2, "writableVotingMembersCount" : 2, "optimes" : { "lastCommittedOpTime" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "lastCommittedWallTime" : ISODate("1970-01-01T00:00:00Z"), "appliedOpTime" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "writtenOpTime": { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "durableOpTime" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "lastAppliedWallTime" : ISODate("1970-01-01T00:00:00Z"), "lastWrittenWallTime": ISODate("1970-01-01T00:00:00Z"), "lastDurableWallTime" : ISODate("1970-01-01T00:00:00Z") }, "lastStableRecoveryTimestamp" : Timestamp(0, 0), "initialSyncStatus" : { "failedInitialSyncAttempts" : 0, "maxFailedInitialSyncAttempts" : 10, "initialSyncStart" : ISODate("2024-08-15T23:06:13.978Z"), "initialSyncAttempts" : [ ], "appliedOps" : 0, "initialSyncOplogStart" : Timestamp(1723763173, 1), "syncSourceUnreachableSince" : ISODate("2024-08-15T23:06:13.978Z"), "currentOutageDurationMillis" : Long(8687), "totalTimeUnreachableMillis" : Long(8687), "databases" : { "databasesCloned" : 3, "admin" : { "collections" : 4, "clonedCollections" : 4, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 429, "admin.system.roles" : { "documentsToCopy" : 22, "documentsCopied" : 22, "indexes" : 2, "fetchedBatches" : 1, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 138, "receivedBatches" : 1 }, "admin.system.users" : { "documentsToCopy" : 32, "documentsCopied" : 32, "indexes" : 2, "fetchedBatches" : 1, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 149, "receivedBatches" : 1 }, "admin.system.keys" : { "documentsToCopy" : 2, "documentsCopied" : 2, "indexes" : 1, "fetchedBatches" : 1, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 76, "receivedBatches" : 1 }, "admin.system.version" : { "documentsToCopy" : 2, "documentsCopied" : 2, "indexes" : 1, "fetchedBatches" : 1, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 66, "receivedBatches" : 1 } }, "config" : { "collections" : 2, "clonedCollections" : 2, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 198, "config.transactions" : { "documentsToCopy" : 0, "documentsCopied" : 0, "indexes" : 1, "fetchedBatches" : 0, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 74, "receivedBatches" : 0 }, "config.system.sessions" : { "documentsToCopy" : 0, "documentsCopied" : 0, "indexes" : 2, "fetchedBatches" : 0, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 124, "receivedBatches" : 0 } }, "test" : { "collections" : 1, "clonedCollections" : 1, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 47967, "test.hugeindex" : { "documentsToCopy" : 25000, "documentsCopied" : 25000, "indexes" : 2, "fetchedBatches" : 21, "start" : ISODate("2024-08-15T23:06:13.978Z"), "end" : ISODate("2024-08-15T23:06:13.978Z"), "elapsedMillis" : 47967, "receivedBatches" : 21 } } } }, "members" : [ { "_id" : 0, "name" : "m1.example.net:27017", "health" : 0, "state" : 8, "stateStr" : "(not reachable/healthy)", "uptime" : 0, "optime" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeWritten" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeDurable" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeDate" : ISODate("1970-01-01T00:00:00Z"), "optimeWrittenDate" : ISODate("1970-01-01T00:00:00Z"), "optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"), "lastAppliedWallTime": ISODate("1970-01-01T00:00:00Z"), "lastWrittenWallTime": ISODate("1970-01-01T00:00:00Z"), "lastDurableWallTime": ISODate("1970-01-01T00:00:00Z""), "lastHeartbeat" : ISODate("2024-08-15T23:06:13.978Z"), "lastHeartbeatRecv" : ISODate("2024-08-15T23:06:13.978Z"), "pingMs" : Long(0), "lastHeartbeatMessage" : "Error connecting to m1.example.net:27017 (127.0.0.1:27018) :: caused by :: Connection refused", "syncSourceHost" : "", "syncSourceId" : -1, "infoMessage" : "", "configVersion" : 2 }, { "_id" : 1, "name" : "m2.example.net:27017", "health" : 1, "state" : 5, "stateStr" : "STARTUP2", "uptime" : 5297, "optime" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeWritten" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeDurable" : { "ts" : Timestamp(0, 0), "t" : Long(-1) }, "optimeDate" : ISODate("1970-01-01T00:00:00Z"), "optimeWrittenDate" : ISODate("1970-01-01T00:00:00Z"), "lastAppliedWallTime": ISODate("1970-01-01T00:00:00Z"), "lastWrittenWallTime": ISODate("2020-03-05T05:24:38Z"), "lastDurableWallTime": ISODate("1970-01-01T00:00:00Z"), "syncSourceHost" : "m1.example.net:27017", "syncSourceId" : 0, "infoMessage" : "", "configVersion" : 2, "configTerm" : 1, "self" : true, "lastHeartbeatMessage" : "" } ], "ok" : 1 }
Output
The replSetGetStatus command returns a document with the following fields:
replSetGetStatus.setThe
setvalue is the name of the replica set, configured in thereplSetNamesetting. This is the same value as_idinrs.conf().
replSetGetStatus.dateAn ISODate formatted date and time that contains the current time according to the server that processed the replSetGetStatus command. Compare this to the values of
replSetGetStatus.members[n].lastHeartbeatto find the operational latency between this server and the other members of the replica set.
replSetGetStatus.myStateAn integer between
0and10that represents the replica state of the current member.
replSetGetStatus.termThe election count for the replica set, as known to this replica set member. The
termis used by the distributed consensus algorithm to ensure correctness.
replSetGetStatus.syncSourceHostThe
syncSourceHostfield holds the hostname of the member from which this instance syncs.If this instance is a primary,
syncSourceHostis an empty string and thesyncSourceId-1.
replSetGetStatus.syncSourceIdThe
syncSourceIdfield holds thereplSetGetStatus.members[n]._idof the member from which this instance synchronizes.If this instance is a primary,
syncSourceHostis an empty string and thesyncSourceId-1.
replSetGetStatus.majorityVoteCountThe number of majority votes needed to elect a new primary in an election.
replSetGetStatus.writeMajorityCountThe number of data-bearing voting members (i.e. not arbiters) needed to fulfill write concern
"majority". Writes can only be applied to data-bearing members.For the calculation of
replSetGetStatus.writeMajorityCount, see Calculating Majority for Write Concern.
replSetGetStatus.votingMembersCountThe number of members configured with
votes: 1, including arbiters.
replSetGetStatus.writableVotingMembersCountThe number of data-bearing members configured with
votes: 1(this does not include arbiters).
replSetGetStatus.optimesThe
optimesfield holds a document that contains optimes used to inspect replication progress. Theoptimesfield includes the corresponding ISODate-formatted date strings for the various optimes.Each optime value is a document that contains:
ts, the Timestamp of the operation.t, thetermin which the operation was originally generated on the primary.
replSetGetStatus.optimes.lastCommittedOpTimeInformation, from the viewpoint of this member, regarding the most recent operation that has been written to a majority of replica set members.
replSetGetStatus.optimes.lastCommittedWallTimeThe ISODate-formatted date string corresponding to
lastCommittedOpTime.
replSetGetStatus.optimes.readConcernMajorityOpTimeInformation, from the viewpoint of this member, regarding the most recent operation that can fulfill read concern
"majority"queries; i.e. the most recentlastCommittedOpTimethat can fulfill"majority"queries.readConcernMajorityOpTimeis either less than or equal tolastCommittedOpTime.
replSetGetStatus.optimes.readConcernMajorityWallTimeThe ISODate-formatted date string corresponding to
readConcernMajorityOpTime.
replSetGetStatus.optimes.appliedOpTimeInformation, from the viewpoint of this member, regarding the most recent operation that has been applied to this member of the replica set.
replSetGetStatus.optimes.lastAppliedWallTimeThe ISODate-formatted date string corresponding to
appliedOpTime.
replSetGetStatus.optimes.durableOpTimeInformation, from the viewpoint of this member, regarding the most recent operation that has been written to the journal of this member of the replica set.
replSetGetStatus.optimes.lastDurableWallTimeThe ISODate-formatted date string corresponding to
durableOpTime.
replSetGetStatus.optimes.lastWrittenWallTimeThe ISODate formatted date string of the most recent entry written to this member's oplog.
New in version 8.0.
replSetGetStatus.optimes.writtenOpTimeThe optime of the most recent entry written to this member's oplog.
New in version 8.0.
replSetGetStatus.electionCandidateMetricsMetrics related to the election of the current primary.
electionCandidateMetricsis only available on the primary or a candidate for election. For a candidate, the metrics are unavailable after the candidate loses the election.replSetGetStatus.electionCandidateMetrics.lastElectionDateThe date and time the member called the election.
replSetGetStatus.electionCandidateMetrics.electionTermThe member's election count (i.e.
term) at the time it called the new election.
replSetGetStatus.electionCandidateMetrics.lastCommittedOpTimeAtElectionThe most recent
majority-committed optime, as seen by this member, at the time it called the new election.
replSetGetStatus.electionCandidateMetrics.lastSeenOpTimeAtElectionThe member's most recent
applied optimeat the time it called the new election.
replSetGetStatus.electionCandidateMetrics.lastSeenWrittenOpTimeAtElectionThe optime of the most recent entry written to this member's oplog at the time it called the new election.
New in version 8.0.
replSetGetStatus.electionCandidateMetrics.numVotesNeededThe number of votes needed to win the election.
replSetGetStatus.electionCandidateMetrics.priorityAtElectionThe member's
priorityat the time it called the election.
replSetGetStatus.electionCandidateMetrics.electionTimeoutMillisThe replica set's configured
electionTimeoutMillissetting at the time of the election.
replSetGetStatus.electionCandidateMetrics.priorPrimaryMemberIdThe
members[n]._idof the previous primary. If there is no previous primary, then the field is not present.
replSetGetStatus.electionCandidateMetrics.targetCatchupOpTimeThe newly-elected primary's target opTime for its catchup process. Only when the newly-elected primary reaches the target catchup opTime can it start accepting writes.
replSetGetStatus.electionCandidateMetrics.numCatchUpOpsThe number of operations applied by the newly-elected primary as it successfully concludes its catchup process.
replSetGetStatus.electionCandidateMetrics.newTermStartDateThe date and time at which the member's term as the primary started (i.e. the date and time at which a
new termentry was written to the oplog).
replSetGetStatus.electionCandidateMetrics.wMajorityWriteAvailabilityDateThe date and time at which the write concern
"majority"became available after the election for the replica set (the date and time when thenew termoplog entry was majority committed).
replSetGetStatus.electionParticipantMetricsMetrics related to the latest election in which the member participated.
replSetGetStatus.electionParticipantMetrics.votedForCandidateA boolean which indicates whether the member voted for the candidate calling the election.
replSetGetStatus.electionParticipantMetrics.electionTermThe term of the election in which the member participated. The term identifies the election associated with the participant metrics.
replSetGetStatus.electionParticipantMetrics.lastVoteDateAn ISODate formatted date string that records when the participant voted.
replSetGetStatus.electionParticipantMetrics.electionCandidateMemberIdThe
members[n]._idof the candidate calling the election.
replSetGetStatus.electionParticipantMetrics.voteReasonThe reason for the vote if the member did not vote for the candidate. If the member voted for the candidate, the value is an empty string.
replSetGetStatus.electionParticipantMetrics.lastAppliedOpTimeAtElectionThis member's latest applied optime at the time of the last election.
The optime value is a document that contains the Timestamp (
ts) and the term (t).
replSetGetStatus.electionParticipantMetrics.lastWrittenOpTimeAtElectionThe optime of the most recent entry written to this member's oplog at the time of the last election.
New in version 8.0.
replSetGetStatus.electionParticipantMetrics.maxAppliedOpTimeInSetThe most recent applied optime for any replica set member, as known to this member.
replSetGetStatus.electionParticipantMetrics.maxWrittenOpTimeInSetThe optime of the most recent entry written to the oplog of any replica set member, as known to this member.
New in version 8.0.
replSetGetStatus.electionParticipantMetrics.priorityAtElectionThe member's
priorityat the time of the election.
replSetGetStatus.electionParticipantMetrics.newTermStartDateThe date and time at which the elected primary's term started; this corresponds to when the primary wrote the
new termentry to its oplog and not when the entry was added (i.e. replicated) to the secondary's oplog.The field is available for secondary members only. For the primary, see
replSetGetStatus.electionCandidateMetrics.newTermStartDateinstead.
replSetGetStatus.initialSyncStatusA document that provides information on the progress and status of initial sync on this member.
Important
Availability
replSetGetStatus.initialSyncStatusmetrics are only available when run on a member during its initial sync (i.e.STARTUP2state).replSetGetStatus.initialSyncStatus.failedInitialSyncAttemptsThe number of times the initial sync failed and had to restart on this member.
replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttemptsThe maximum number of times the initial sync can restart on this member before the member shuts down.
replSetGetStatus.initialSyncStatus.initialSyncStartThe start timestamp of the initial sync for this member.
replSetGetStatus.initialSyncStatus.initialSyncEndThe end timestamp of the initial sync for this member.
replSetGetStatus.initialSyncStatus.initialSyncElapsedMillisThe number of milliseconds between
initialSyncStartandinitialSyncEnd.
replSetGetStatus.initialSyncStatus.initialSyncAttemptsArray of documents where each document corresponds to a single initial sync attempt. For example:
"initialSyncAttempts" : [ { "durationMillis" : 59539, "status" : "InvalidOptions: error fetching oplog during initial sync :: caused by :: Error while getting the next batch in the oplog fetcher :: caused by :: readConcern afterClusterTime value must not be greater than the current clusterTime. Requested clusterTime: { ts: Timestamp(0, 1) }; current clusterTime: { ts: Timestamp(0, 0) }", "syncSource" : "m1.example.net:27017", "rollBackId" : 1, "operationsRetried" : 120, "totalTimeUnreachableMillis" : 52601 } ], Each document contains the following information for the initial sync attempt:
FieldDescriptiondurationMillis
Duration in milliseconds of the initial sync attempt.
status
Exit status of the initial sync attempt.
syncSource
Sync source for the initial sync attempt.
rollBackId
The sync source's rollback identifier at the start of the initial sync attempt.
rollBackIddoes not appear when using file copy based initial sync.operationsRetried
Total number of all operation retry attempts.
totalTimeUnreachableMillis
Total time spent for retry operation attempts.
See also
failedInitialSyncAttempts.
replSetGetStatus.initialSyncStatus.appliedOpsThe number of ops that occurred after the initial sync started and were applied after cloning the databases.
As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.
replSetGetStatus.initialSyncStatus.initialSyncOplogStartThe start timestamp of the oplog application stage of the initial sync where the member applies changes that occurred after the initial sync start.
As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.
replSetGetStatus.initialSyncStatus.initialSyncOplogEndThe end timestamp of the oplog application stage of the initial sync where the member applies changes that occurred after the initial sync start.
As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.
replSetGetStatus.initialSyncStatus.syncSourceUnreachableSinceThe date and time at which the sync source became unreachable.
Only present if the if sync source is unavailable during the current initial sync.
replSetGetStatus.initialSyncStatus.currentOutageDurationMillisThe time in milliseconds that the sync source has been unavailable.
Only present if the if sync source is unavailable during the current initial sync.
replSetGetStatus.initialSyncStatus.totalTimeUnreachableMillisThe total time in milliseconds that the member has been unavailable during the current initial sync.
replSetGetStatus.initialSyncStatus.databasesDetail on the databases cloned during initial sync.
replSetGetStatus.initialSyncStatus.databases.databasesClonedNumber of databases cloned during initial sync.
replSetGetStatus.initialSyncStatus.databases.<dbname>For each database, a document that returns information regarding the progress of the cloning of that database.
{ "collections" : <number of collections to clone in the database>, "clonedCollections" : <number of collections cloned to date>, "start" : <start date and time for the database clone>, "end" : <end date and time for the database clone>, "elapsedMillis" : <duration of the database clone>, "<db>.<collection>" : { "documentsToCopy" : <number of documents to copy>, "documentsCopied" : <number of documents copied to date>, "indexes" : <number of indexes>, "fetchedBatches" : <number of batches of documents fetched to date>, "start" : <start date and time for the collection clone>, "end" : <end date and time for the collection clone>, "elapsedMillis" : <duration of the collection clone>, "receivedBatches" : <number of batches of documents received to date> } }
replSetGetStatus.initialSyncStatus.methodNew in version 5.2.
The method used for the initial sync.
If set to
logical, the sync is a logical initial sync. If set tofileCopyBased, the sync is a file copy based initial sync.
replSetGetStatus.initialSyncStatus.approxTotalDataSizeThe approximate size (in bytes) of all files to be synced.
This field appears when using either logical or file copy based initial sync.
replSetGetStatus.initialSyncStatus.approxTotalBytesCopiedThe total bytes already copied.
This field appears when using either logical or file copy based initial sync.
replSetGetStatus.initialSyncStatus.totalInitialSyncElapsedMillisThe total time elapsed for the sync attempt in progress.
This field appears when using either logical or file copy based initial sync.
replSetGetStatus.initialSyncStatus.remainingInitialSyncEstimatedMillisThe expected time remaining for the sync attempt in progress.
This field appears when using either logical or file copy based initial sync.
replSetGetStatus.initialSyncStatus.initialBackupDataSizeThe total size (in bytes) of the initial set of files to be synced.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.previousOplogEndThe optime available in the previous backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.currentOplogEndThe last optime guaranteed to be available in the current backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.syncSourceLastAppliedThe optime of the last update applied at the sync source prior to the start of this backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.numExtensionsThe number of times the sync has started a new backup cursor.
This field does not appear if a backup cursor has not started.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.extensionDataSizeThe total bytes in the current extension.
This field does not appear if there is no extension in progress.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.filesAn array of files to be synced during file copy based initial sync.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].filePathThe path of the file relative to the root of the backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].fileSizeThe size of the file as reported by the backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].bytesCopiedThe number of bytes copied so far.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].extensionNumberThe number of the extension the file belongs to if this file is part of an extension.
This field only appears when using file copy based initial sync.
replSetGetStatus.membersThe
membersfield holds an array that contains a document for every member in the replica set.replSetGetStatus.members[n].ipThe resolved IP address of the member. If the
mongodis unable to resolve thereplSetGetStatus.members[n].nameto an IP address, the return value is a BSON null. Otherwise, the returned value is a string representation of the resolved IP address.
replSetGetStatus.members[n].selfA boolean that indicates if the member is the current
mongodinstance.The
selffield is only included in the document for the currentmongodinstance, and as such, its value is alwaystrue.
replSetGetStatus.members[n].stateAn integer between
0and10that represents the replica state of the member.
replSetGetStatus.members[n].stateStrA string that describes
state.
replSetGetStatus.members[n].uptimeFor the member on which the
replSetGetStatuscommand is run,uptimeis the the number of seconds the member has been online.For the other members,
uptimeis the number of seconds the member has been in continuous communication with the member on which thereplSetGetStatuscommand was run.
replSetGetStatus.members[n].optimeInformation regarding the last operation from the operation log that this member has applied.
optimereturns a document that contains:
replSetGetStatus.members[n].optimeDurableInformation regarding the last operation from the operation log that this member has applied to its journal.
optimeDurablereturns a document that contains:
replSetGetStatus.members[n].optimeDateAn ISODate formatted date string that contains the last entry from the oplog that this member applied. If this differs significantly from
lastHeartbeatthis member is either experiencing "replication lag" or there have not been any new operations after the last update. Comparemembers.optimeDatebetween all of the members of the set.
replSetGetStatus.members[n].optimeDurableDateAn ISODate formatted date string that contains the last entry from the oplog that this member applied to its journal.
replSetGetStatus.members[n].lastAppliedWallTimeAn ISODate formatted date string reflecting the wall clock time at which the last operation applied by this member of the replica set was applied on the primary node.
replSetGetStatus.members[n].lastDurableWallTimeAn ISODate formatted date string reflecting the wall clock time at which the last operation written to this member's journal was first applied on the primary node.
replSetGetStatus.members[n].electionTimeFor the current primary, information regarding the election Timestamp from the operation log. See Replica Set High Availability for more information about elections.
replSetGetStatus.members[n].electionDateFor the current primary, an ISODate formatted date string that contains the election date. See Replica Set High Availability for more information about elections.
replSetGetStatus.members[n].lastHeartbeatAn ISODate formatted date and time that contains the last time the server that processed the replSetGetStatus command received a response from a heartbeat that it sent to this member (
members[n]). Compare this value to the values of thedateandlastHeartbeatRecvfields to track latency between these replica set members.This value is only available for replica set members other than the server specified by
replSetGetStatus.members[n].self.
replSetGetStatus.members[n].lastHeartbeatRecvAn ISODate formatted date and time that contains the last time the server that processed the replSetGetStatus command received a heartbeat request from this member (
members[n]). Compare this value to the values of thedateandlastHeartbeatfields to track latency between these replica set members.This value is only available for replica set members other than the server specified by
replSetGetStatus.members[n].self.
replSetGetStatus.members[n].lastHeartbeatMessageWhen the last heartbeat included an extra message, the
lastHeartbeatMessagecontains a string representation of that message.
replSetGetStatus.members[n].pingMsThe
pingMsrepresents 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].syncSourceHostThe
syncSourceHostfield holds the hostname of the member from which this instance syncs.If the
replSetGetStatus.members[n]is a primary,syncSourceHostis an empty string and thesyncSourceId-1.
replSetGetStatus.members[n].syncSourceIdThe
syncSourceIdfield holds thereplSetGetStatus.members[n]._idvalue of thesyncSourceHost.If the
replSetGetStatus.members[n]is a primary,syncSourceHostis an empty string and thesyncSourceId-1.
replSetGetStatus.members[n].configVersionThe
configVersionvalue is thereplica set configuration version.
replSetGetStatus.members[n].optimeWrittenThe optime of the most recent entry written to the member's oplog.
New in version 8.0.
replSetGetStatus.members[n].optimeWrittenDateThe ISODate formatted date string of the most recent entry written to the member's oplog.
New in version 8.0.
replSetGetStatus.members[n].lastWrittenWallTimeThe ISODate formatted date string of the time when the most recent oplog entry for this member was written on the primary.
New in version 8.0.
replSetGetStatus.tooStaleA boolean which indicates that a replica set member has fallen too far behind the primary's oplog and is stuck in the
RECOVERINGstate. This field is only included in thereplSetGetStatusoutput if its value istrue.
See also Response for details on the ok status
field, the operationTime field and the $clusterTime field.
replSetGetStatus.optimePresent after the removal of a member from the replica set. Provides the optime of the last oplog entry applied by the removed member.
replSetGetStatus.optimeDatePresent after the removal of a member from the replica set. Provides the ISODate formatted string of the optime of the last oplog entry applied by the removed member.
replSetGetStatus.optimeWrittenPresent after the removal of a member from the replica set. Provides the optime of the last entry written to the oplog of the removed member.
New in version 8.0.
replSetGetStatus.optimeWrittenDatePresent after the removal of a member from the replica set. Provides the ISODate formatted string of the optime of the last entry written to the oplog of the removed member.
New in version 8.0.