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.从运行该方法的成员的角度返回副本集状态。Importantmongosh 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.有关输出的示例和详细信息,请参阅replSetGetStatus。
-
Starting in MongoDB 4.2.1从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.STARTUP2状态)期间对其运行mongosh助手方法rs.status()(或replSetGetStatus命令),则该命令将返回replSetGetStatus.initialSyncStatus度量。Once the member completes its initial sync, the一旦成员完成初始同步,replSetGetStatus.initialSyncStatusmetrics becomes unavailable.replSetGetStatus.initialSyncStatus度量将不可用。
-
In earlier versions (3.4.x-4.2.0)在早期版本中(3.4x-4.2.0)-
To return initial sync status information, you must the要返回初始同步状态信息,必须在辅助成员或replSetGetStatuscommand with theinitialSync: 1option on a secondary member or a member inSTARTUP2state:STARTUP2状态的成员上使用带有initialSync:1选项的replSetGetStatus命令:db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } )
The成员完成初始同步后,replSetGetStatus.initialSyncStatusmetrics remains available after the member completes its initial sync.replSetGetStatus.initialSyncStatus度量仍然可用。That is, you can run the也就是说,您可以在辅助成员上使用replSetGetStatuscommand with theinitialSync: 1on the secondary member to return its initial sync information.initialSync:1运行replSetGetStatus命令,以返回其初始同步信息。You cannot specify不能将initialSync: 1to themongoshhelper methodrs.status().initialSync:1指定给mongosh助手方法rs.status()。