定义
replSetGetStatusreplSetGetStatus命令从处理该命令的服务器的角度返回副本集的状态。在管理员数据库上运行replSetGetStatus。The
mongodinstance must be a replica set member forreplSetGetStatusto return successfully.此命令的数据来源于其他副本集成员发送的心跳。由于心跳频率,这些数据可能会过时几秒。
提示
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.
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { replSetGetStatus: 1 } )
If you run replSetGetStatus or the mongosh helper rs.status() on a member during its initial sync in the 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.
注意
如果尚未initialized副本集, replSetGetStatus命令将返回以下错误:
MongoServerError: no replset config has been received
运行replSetInitiate命令并重试。
例子
The following example runs the replSetGetStatus command on the admin database of the replica set primary:
db.adminCommand( { replSetGetStatus: 1 } )
此命令将返回一个示例副本集主节点的如下输出:
{ "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) }, "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 } )
该命令将返回一个示例副本集从节点的如下输出:
{ "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) }, "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), }
- 在早期版本(3.4.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 } )
- 从 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.
replSetGetStatus4以下示例在初始同步期间对.4 副本集成员的管理员数据库运行 命令:
{ "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 }
输出
replSetGetStatus 命令会返回一个包含以下字段的文件:
replSetGetStatus.setset值是副本集的名称,在replSetName设置中配置。这与rs.conf()中的_id值相同。
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.myState介于
0和10之间的整数,表示当前成员的副本状态。
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.writeMajorityCount满足写关注(write concern)
"majority"所需的数据承载投票节点数量。写入操作只能应用于数据承载节点。For the calculation of
replSetGetStatus.writeMajorityCount, see Calculating Majority for Write Concern.
replSetGetStatus.votingMembersCount使用
votes: 1配置的成员数,包括仲裁节点。
replSetGetStatus.writableVotingMembersCount使用
votes: 1配置的数据承载成员的数量(不包括仲裁节点)。
replSetGetStatus.optimesoptimes字段包含一个文档,其中包含用于检查复制进度的 optime。optimes字段包括各种操作时间的相应 ISODate 格式的日期字符串。每个 ops/sec 值均为一个包含以下内容的文档:
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. That is, the most recentlastCommittedOpTimethat can fulfill"majority"queries.readConcernMajorityOpTimeis either less than or equal tolastCommittedOpTime.
replSetGetStatus.optimes.lastAppliedWallTimeThe ISODate-formatted date string corresponding to
appliedOpTime.
replSetGetStatus.optimes.lastDurableWallTimeThe ISODate-formatted date string corresponding to
durableOpTime.
replSetGetStatus.optimes.lastWrittenWallTime写入该成员 oplog 的最新条目的 ISODate 格式日期字符串。
8.0版本新增。
replSetGetStatus.optimes.writtenOpTime写入该成员 oplog 的最新条目的 optime。
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.electionTermThe member's election count (that is,
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.lastSeenWrittenOpTimeAtElection在调用新选举时,写入该节点的 oplog 的最新条目的 optime 。
8.0版本新增。
replSetGetStatus.electionCandidateMetrics.priorityAtElection宣布选举时该成员的
priority。
replSetGetStatus.electionCandidateMetrics.electionTimeoutMillis选举时副本集已配置的
electionTimeoutMillis设置。
replSetGetStatus.electionCandidateMetrics.priorPrimaryMemberId上一个主节点的
members[n]._id。如果没有以前的主节点,则该字段不存在。
replSetGetStatus.electionCandidateMetrics.targetCatchupOpTime新当选的主节点的目标 ops/sec 用于其追赶过程。只有当新当选的主节点达到目标追赶 ops/sec 时,它才能开始接受写入。
replSetGetStatus.electionCandidateMetrics.newTermStartDate成员作为主节点的时段开始的日期和时间(即
new term条目写入 oplog 的日期和时间)。
replSetGetStatus.electionCandidateMetrics.wMajorityWriteAvailabilityDate在副本集选举后,写关注
"majority"可用的日期和时间(new termoplog 条目被多数提交的日期和时间)。
replSetGetStatus.electionParticipantMetrics与节点参与的最近一次选举相关的指标。
replSetGetStatus.electionParticipantMetrics.lastVoteDate记录参与者投票时间的 ISODate 格式的日期字符串。
replSetGetStatus.electionParticipantMetrics.electionCandidateMemberId召集选举的候选节点的
members[n]._id。
replSetGetStatus.electionParticipantMetrics.voteReason如果该成员未投票给候选节点,那么投票的原因是什么。如果该成员投票给候选节点,则该值为空字符串。
replSetGetStatus.electionParticipantMetrics.lastAppliedOpTimeAtElection该成员在上次选举时最近一次应用的 optime。
ops/sec 值是一个包含时间戳 (
ts) 和任期 (t) 的文档。
replSetGetStatus.electionParticipantMetrics.lastWrittenOpTimeAtElection在上次选举时写入此节点的 oplog 的最新条目的 optime。
8.0版本新增。
replSetGetStatus.electionParticipantMetrics.maxWrittenOpTimeInSet写入任何副本集节点的 oplog 的最新条目的 optime ,如该节点已知。
8.0版本新增。
replSetGetStatus.electionParticipantMetrics.priorityAtElection选举时该成员的
priority。
replSetGetStatus.electionParticipantMetrics.newTermStartDate当选的主节点任期的开始日期和时间;这对应于主节点将
new term条目写入其 oplog 的时间,而不是该条目被添加(即复制)到从节点的 oplog 的时间。The field is available for secondary members only. For the primary, see
replSetGetStatus.electionCandidateMetrics.newTermStartDateinstead.
replSetGetStatus.initialSyncStatus提供有关该成员初始同步进度和状态信息的文档。
重要
可用性
replSetGetStatus.initialSyncStatusmetrics are only available when run on a member during its initial sync, in theSTARTUP2state.replSetGetStatus.initialSyncStatus.failedInitialSyncAttempts初始同步失败的次数,在此失败次数后成员必须重新启动。
replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttempts在该成员关闭之前,可以在该成员上重新启动初始同步的最大次数。
replSetGetStatus.initialSyncStatus.initialSyncStart该成员的初始同步的起始时间戳。
replSetGetStatus.initialSyncStatus.initialSyncEnd此成员的 initial sync 的结束时间戳。
replSetGetStatus.initialSyncStatus.initialSyncElapsedMillisThe number of milliseconds between
initialSyncStartandinitialSyncEnd.
replSetGetStatus.initialSyncStatus.initialSyncAttempts文档数组,其中每个文档均对应一次初始同步尝试。例如:
"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 } ], 每份文档都包含以下用于初始同步尝试的信息:
字段说明durationMillis
初始同步尝试的持续时间(以毫秒为单位)。
状态
初始同步尝试的退出状态。
syncSource
初始同步尝试的同步源。
rollBackId
初始同步尝试开始时同步源的回滚标识符。
rollBackId在使用基于文件复制的初始同步时不会出现。operationsRetried
所有操作重试的总次数。
totalTimeUnreachableMillis
重试操作尝试所花费的总时间。
See also
failedInitialSyncAttempts.
replSetGetStatus.initialSyncStatus.appliedOps初始同步开始后发生并在复制数据库后应用的操作数。
作为初始同步过程的一部分,该成员会使用 oplog 更新其数据集以反映副本集的当前状态。
replSetGetStatus.initialSyncStatus.initialSyncOplogStart初始同步的 oplog 应用程序阶段的开始时间戳,成员在此阶段会应用初始同步开始后发生的更改。
作为初始同步过程的一部分,该成员会使用 oplog 更新其数据集以反映副本集的当前状态。
replSetGetStatus.initialSyncStatus.initialSyncOplogEnd初始同步的 oplog 应用程序阶段的结束时间戳,成员在此阶段会应用初始同步开始后发生的更改。
作为初始同步过程的一部分,该成员会使用 oplog 更新其数据集以反映副本集的当前状态。
replSetGetStatus.initialSyncStatus.syncSourceUnreachableSince同步源变得无法访问的日期和时间。
只有在当前初始同步期间同步源不可用时才会出现。
replSetGetStatus.initialSyncStatus.currentOutageDurationMillis同步源不可用的时长(以毫秒为单位)。
只有在当前初始同步期间同步源不可用时才会出现。
replSetGetStatus.initialSyncStatus.databases初始同步期间所克隆数据库的相关详细信息。
replSetGetStatus.initialSyncStatus.databases.databasesCloned初始同步时克隆的数据库数量。
replSetGetStatus.initialSyncStatus.databases.<dbname>对于每个数据库,这是一份返回该数据库克隆进度信息的文档。
{ "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.method5.2版本新增。
用于初始同步的方法。
如果设立为
logical,则同步是逻辑初始同步。如果设立为fileCopyBased,则同步是基于文件副本的初始同步。
replSetGetStatus.initialSyncStatus.approxTotalDataSize待同步的所有文件的大致大小(以字节为单位)。
此字段会在使用基于逻辑或文件副本的初始同步时出现。
replSetGetStatus.initialSyncStatus.totalInitialSyncElapsedMillis正在进行的同步尝试所耗费的总时间。
此字段会在使用基于逻辑或文件副本的初始同步时出现。
replSetGetStatus.initialSyncStatus.remainingInitialSyncEstimatedMillis正在进行的同步尝试的预期剩余时间。
此字段会在使用基于逻辑或文件副本的初始同步时出现。
replSetGetStatus.initialSyncStatus.initialBackupDataSize要同步的初始文件集的总大小(以字节为单位)。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.syncSourceLastApplied在此备份游标开始之前,在同步源上应用的最后一次更新的 ops/sec。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.numExtensions同步已启动新备份游标的次数。
如果备份游标尚未启动,则不会显示此字段。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.extensionDataSize当前扩展中的总字节数。
如果没有正在进行的扩展,则不会显示此字段。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.files基于文件拷贝的初始同步过程中要同步的文件数组。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.files[n].filePath此文件相对于备份游标根目录的路径。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.files[n].fileSize备份游标所报告的文件大小。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.initialSyncStatus.files[n].extensionNumber如果此文件是某个扩展的一部分,则该文件所属扩展的名称。
此字段仅在使用基于文件拷贝的初始同步时出现。
replSetGetStatus.membersmembers字段保存一个数组,其中包含副本集中每个成员的文档。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].self布尔值,表示该成员是否为当前
mongod实例。self字段仅包含在当前mongod实例的文档中,因此其值始终为true。
replSetGetStatus.members[n].state介于
0和10之间的整数,表示成员的副本状态。
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].optime关于该成员应用的来自操作日志的最后一次操作的信息。
optime返回一个包含以下内容的文档:t, thetermin which the last applied operation was originally generated on the primary.
replSetGetStatus.members[n].optimeDurable关于该成员已应用到其日志的来自 oplog 的最后一次操作的信息。
optimeDurable返回一个包含以下内容的文档:
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].lastAppliedWallTimeISODate格式的日期string,反映副本集的节点在主节点 (primary node in the replica set)节点上应用的最后一次操作的挂钟时间。
replSetGetStatus.members[n].lastDurableWallTimeISODate 格式的日期字符串,反映最后一次写入该节点日志记录的操作首次应用于主节点 (primary node in the replica set)节点的挂钟时间。
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].pingMspingMs表示往返数据包在远程成员和本地实例之间传输所需的毫秒 (ms) 数。该值不会出现在返回
rs.status()数据的节点中。
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].configVersionconfigVersion值是replica set configuration version。
replSetGetStatus.members[n].optimeWritten写入节点的 oplog 的最新条目的 optime。
8.0版本新增。
replSetGetStatus.members[n].optimeWrittenDate写入节点 oplog 的最新条目的 ISODate 格式日期字符串。
8.0版本新增。
replSetGetStatus.members[n].lastWrittenWallTime该节点的最新 oplog 条目在主节点写入时间的 ISODate 格式的日期字符串。
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.
有关 ok 状态字段、operationTime 字段和 $clusterTime 字段的详情,另请参阅响应。
replSetGetStatus.optime从副本集删除节点后出现。提供已删除节点应用的最后一个 oplog 条目的 optime。
replSetGetStatus.optimeDate从副本集删除节点后出现。提供已删除节点应用的最后一个 oplog 条目的 optime 的 ISODate 格式字符串。
replSetGetStatus.optimeWritten从副本集删除成员后出现。提供写入被删除成员的 oplog 的最后一项的 optime。
8.0版本新增。
replSetGetStatus.optimeWrittenDate从副本集删除节点后出现。提供写入已删除节点的 oplog 中的最后一个条目的 optime 的 ISODate 格式的字符串。
8.0版本新增。