rs.status()
On this page
Definition
rs.status()-
Returns the replica set status from the point of view of the member where the method is run.
Important
mongosh Method
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
replSetGetStatuscommand.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:This output reflects the current status of the replica set, using data derived from the heartbeat packets sent by the other members of the replica set.
Output
For an example and details on the output, see replSetGetStatus.
- Starting in MongoDB 4.2.1
-
If you run the
mongoshhelper methodrs.status()(or thereplSetGetStatuscommand) on a member during its initial sync (i.e.STARTUP2state), the command returnsreplSetGetStatus.initialSyncStatusmetrics.Once the member completes its initial sync, the
replSetGetStatus.initialSyncStatusmetrics becomes unavailable.
- In earlier versions (3.4.x-4.2.0)
-
To return initial sync status information, you must the
replSetGetStatuscommand with theinitialSync: 1option on a secondary member or a member inSTARTUP2state:db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } )
The
replSetGetStatus.initialSyncStatusmetrics remains available after the member completes its initial sync. That is, you can run thereplSetGetStatuscommand with theinitialSync: 1on the secondary member to return its initial sync information.You cannot specify
initialSync: 1to themongoshhelper methodrs.status().