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
mongosh
method. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
replSetGetStatus
command.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongo
shell 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如果在成员的初始同步(即mongosh
helper methodrs.status()
(or thereplSetGetStatus
command) on a member during its initial sync (i.e.STARTUP2
state), the command returnsreplSetGetStatus.initialSyncStatus
metrics.STARTUP2
状态)期间对其运行mongosh
助手方法rs.status()
(或replSetGetStatus
命令),则该命令将返回replSetGetStatus.initialSyncStatus
度量。Once the member completes its initial sync, the一旦成员完成初始同步,replSetGetStatus.initialSyncStatus
metrics 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要返回初始同步状态信息,必须在辅助成员或replSetGetStatus
command with theinitialSync: 1
option on a secondary member or a member inSTARTUP2
state:STARTUP2
状态的成员上使用带有initialSync:1
选项的replSetGetStatus
命令:db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } )
The成员完成初始同步后,replSetGetStatus.initialSyncStatus
metrics remains available after the member completes its initial sync.replSetGetStatus.initialSyncStatus
度量仍然可用。That is, you can run the也就是说,您可以在辅助成员上使用replSetGetStatus
command with theinitialSync: 1
on the secondary member to return its initial sync information.initialSync:1
运行replSetGetStatus
命令,以返回其初始同步信息。You cannot specify不能将initialSync: 1
to themongosh
helper methodrs.status()
.initialSync:1
指定给mongosh
助手方法rs.status()
。