对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

replSetGetStatus(数据库命令)

replSetGetStatus

replSetGetStatus 命令从处理该命令的服务器的角度返回副本集的状态。在管理员数据库上运行 replSetGetStatus

The mongod instance must be a replica set member for replSetGetStatus to return successfully.

此命令的数据来源于其他副本集成员发送的心跳。由于心跳频率,这些数据可能会过时几秒。

提示

In mongosh, this command can also be run through the rs.status() helper method.

Helper methods are convenient for mongosh users, 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 集群不支持此命令。有关更多信息,请参阅不支持的命令。

该命令具有以下语法:

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: 1 to include the replSetGetStatus.initialSyncStatus in 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.initialSyncStatus document 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.set

set 值是副本集的名称,在replSetName 设置中配置。这与 rs.conf() 中的 _id 值相同。

replSetGetStatus.date

An 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].lastHeartbeat to find the operational latency between this server and the other members of the replica set.

replSetGetStatus.myState

介于 010 之间的整数,表示当前成员的副本状态

replSetGetStatus.term

The election count for the replica set, as known to this replica set member. The term is used by the distributed consensus algorithm to ensure correctness.

replSetGetStatus.syncSourceHost

The syncSourceHost field holds the hostname of the member from which this instance syncs.

If this instance is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.syncSourceId

The syncSourceId field holds the replSetGetStatus.members[n]._id of the member from which this instance synchronizes.

If this instance is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.heartbeatIntervalMillis

心跳频率(以毫秒为单位)。

replSetGetStatus.majorityVoteCount

在选举中选出新的主节点所需的多数票数。

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.optimes

optimes 字段包含一个文档,其中包含用于检查复制进度的 optimeoptimes 字段包括各种操作时间的相应 ISODate 格式的日期字符串。

每个 ops/sec 值均为一个包含以下内容的文档:

  • ts,操作的时间戳

  • t, the term in which the operation was originally generated on the primary.

replSetGetStatus.optimes.lastCommittedOpTime

从该成员的角度来看,有关最近一次写入大多数副本集成员的操作的信息。

replSetGetStatus.optimes.lastCommittedWallTime

The ISODate-formatted date string corresponding to lastCommittedOpTime.

replSetGetStatus.optimes.readConcernMajorityOpTime

Information, from the viewpoint of this member, regarding the most recent operation that can fulfill read concern "majority" queries. That is, the most recent lastCommittedOpTime that can fulfill "majority" queries. readConcernMajorityOpTime is either less than or equal to lastCommittedOpTime.

replSetGetStatus.optimes.appliedOpTime

从该成员的角度来看,有关最近一次应用于该副本集成员的操作的信息。

replSetGetStatus.optimes.lastAppliedWallTime

The ISODate-formatted date string corresponding to appliedOpTime.

replSetGetStatus.optimes.durableOpTime

从该成员的角度来看,有关最近一次写入该副本集成员日志的操作的信息。

replSetGetStatus.optimes.lastDurableWallTime

The ISODate-formatted date string corresponding to durableOpTime.

replSetGetStatus.optimes.lastWrittenWallTime

写入该成员 oplog 的最新条目的 ISODate 格式日期字符串。

8.0版本新增。

replSetGetStatus.optimes.writtenOpTime

写入该成员 oplog 的最新条目的 optime

8.0版本新增。

replSetGetStatus.lastStableRecoveryTimestamp

仅供内部使用

replSetGetStatus.electionCandidateMetrics

Metrics related to the election of the current primary. electionCandidateMetrics is 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.lastElectionReason

成员宣布选举的原因。

replSetGetStatus.electionCandidateMetrics.lastElectionDate

该成员发起选举的日期和时间。

replSetGetStatus.electionCandidateMetrics.electionTerm

The member's election count (that is, term) at the time it called the new election.

replSetGetStatus.electionCandidateMetrics.lastCommittedOpTimeAtElection

The most recent majority-committed optime, as seen by this member, at the time it called the new election.

replSetGetStatus.electionCandidateMetrics.lastSeenOpTimeAtElection

The member's most recent applied optime at the time it called the new election.

replSetGetStatus.electionCandidateMetrics.lastSeenWrittenOpTimeAtElection

在调用新选举时,写入该节点的 oplog 的最新条目的 optime

8.0版本新增。

replSetGetStatus.electionCandidateMetrics.numVotesNeeded

赢得选举所需的票数。

replSetGetStatus.electionCandidateMetrics.priorityAtElection

宣布选举时该成员的priority

replSetGetStatus.electionCandidateMetrics.electionTimeoutMillis

选举时副本集已配置的 electionTimeoutMillis 设置。

replSetGetStatus.electionCandidateMetrics.priorPrimaryMemberId

上一个主节点的 members[n]._id。如果没有以前的主节点,则该字段不存在。

replSetGetStatus.electionCandidateMetrics.targetCatchupOpTime

新当选的主节点的目标 ops/sec 用于其追赶过程。只有当新当选的主节点达到目标追赶 ops/sec 时,它才能开始接受写入。

replSetGetStatus.electionCandidateMetrics.numCatchUpOps

新当选的主节点在成功结束追赶过程时所应用的操作数量。

replSetGetStatus.electionCandidateMetrics.newTermStartDate

成员作为主节点的时段开始的日期和时间(即 new term 条目写入 oplog 的日期和时间)。

replSetGetStatus.electionCandidateMetrics.wMajorityWriteAvailabilityDate

在副本集选举后,写关注 "majority" 可用的日期和时间(new term oplog 条目被多数提交的日期和时间)。

replSetGetStatus.electionParticipantMetrics

与节点参与的最近一次选举相关的指标。

replSetGetStatus.electionParticipantMetrics.votedForCandidate

布尔值,表示该节点是否投票支持召集选举的候选节点。

replSetGetStatus.electionParticipantMetrics.electionTerm

成员所参与选举的任期。该任期可标识与参与者指标关联的选举。

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.maxAppliedOpTimeInSet

如该节点所知,为任何副本集节点最近一次应用的 optime。

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.newTermStartDate instead.

replSetGetStatus.electionParticipantMetrics.newTermAppliedDate

此从节点应用 new term 条目的日期和时间。

该字段仅适用于从节点。

replSetGetStatus.initialSyncStatus

提供有关该成员初始同步进度和状态信息的文档。

重要

可用性

replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync, in the STARTUP2 state.

replSetGetStatus.initialSyncStatus.failedInitialSyncAttempts

初始同步失败的次数,在此失败次数后成员必须重新启动。

replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttempts

在该成员关闭之前,可以在该成员上重新启动初始同步的最大次数。

replSetGetStatus.initialSyncStatus.initialSyncStart

该成员的初始同步的起始时间戳。

replSetGetStatus.initialSyncStatus.initialSyncEnd

此成员的 initial sync 的结束时间戳。

replSetGetStatus.initialSyncStatus.initialSyncElapsedMillis

The number of milliseconds between initialSyncStart and initialSyncEnd.

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.totalTimeUnreachableMillis

当前初始同步期间该成员不可用的总时长(以毫秒为单位)。

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.method

5.2版本新增。

用于初始同步的方法。

如果设立为 logical,则同步是逻辑初始同步。如果设立为 fileCopyBased,则同步是基于文件副本的初始同步。

replSetGetStatus.initialSyncStatus.approxTotalDataSize

待同步的所有文件的大致大小(以字节为单位)。

此字段会在使用基于逻辑或文件副本的初始同步时出现。

replSetGetStatus.initialSyncStatus.approxTotalBytesCopied

已复制的总字节数。

此字段会在使用基于逻辑或文件副本的初始同步时出现。

replSetGetStatus.initialSyncStatus.totalInitialSyncElapsedMillis

正在进行的同步尝试所耗费的总时间。

此字段会在使用基于逻辑或文件副本的初始同步时出现。

replSetGetStatus.initialSyncStatus.remainingInitialSyncEstimatedMillis

正在进行的同步尝试的预期剩余时间。

此字段会在使用基于逻辑或文件副本的初始同步时出现。

replSetGetStatus.initialSyncStatus.initialBackupDataSize

要同步的初始文件集的总大小(以字节为单位)。

此字段仅在使用基于文件拷贝的初始同步时出现。

replSetGetStatus.initialSyncStatus.previousOplogEnd

前一备份游标中可用的 ops/sec

此字段仅在使用基于文件拷贝的初始同步时出现。

replSetGetStatus.initialSyncStatus.currentOplogEnd

保证在当前备份游标中可用的最后一个 ops/sec

此字段仅在使用基于文件拷贝的初始同步时出现。

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].bytesCopied

目前已复制的字节数。

此字段仅在使用基于文件拷贝的初始同步时出现。

replSetGetStatus.initialSyncStatus.files[n].extensionNumber

如果此文件是某个扩展的一部分,则该文件所属扩展的名称。

此字段仅在使用基于文件拷贝的初始同步时出现。

replSetGetStatus.members

members 字段保存一个数组,其中包含副本集中每个成员的文档。

replSetGetStatus.members[n]._id

成员的标识符。

replSetGetStatus.members[n].name

该成员的名称。

replSetGetStatus.members[n].ip

The resolved IP address of the member. If the mongod is unable to resolve the replSetGetStatus.members[n].name to 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].health

一个表示该成员是处于活动状态 (1) 还是非活动状态 (0) 的数字。

replSetGetStatus.members[n].state

介于 010 之间的整数,表示成员的副本状态

replSetGetStatus.members[n].stateStr

A string that describes state.

replSetGetStatus.members[n].uptime

For the member on which the replSetGetStatus command is run, uptime is the the number of seconds the member has been online.

For the other members, uptime is the number of seconds the member has been in continuous communication with the member on which the replSetGetStatus command was run.

replSetGetStatus.members[n].optime

关于该成员应用的来自操作日志的最后一次操作的信息。

optime 返回一个包含以下内容的文档:

  • ts,对 oplog 副本集的该节点应用最后一次操作的 时间戳

  • t, the term in which the last applied operation was originally generated on the primary.

replSetGetStatus.members[n].optimeDurable

关于该成员已应用到其日志的来自 oplog 的最后一次操作的信息。

optimeDurable 返回一个包含以下内容的文档:

  • ts,操作的时间戳

  • t, the term in which this operation was originally generated on the primary.

replSetGetStatus.members[n].optimeDate

An ISODate formatted date string that contains the last entry from the oplog that this member applied. If this differs significantly from lastHeartbeat this member is either experiencing "replication lag" or there have not been any new operations after the last update. Compare members.optimeDate between all of the members of the set.

replSetGetStatus.members[n].optimeDurableDate

一个 ISODate 格式的日期字符串,其中包含 oplog 中该成员应用于其日记中的最后一个条目。

replSetGetStatus.members[n].lastAppliedWallTime

ISODate格式的日期string,反映副本集的节点在主节点 (primary node in the replica set)节点上应用的最后一次操作的挂钟时间

replSetGetStatus.members[n].lastDurableWallTime

ISODate 格式的日期字符串,反映最后一次写入该节点日志记录的操作首次应用于主节点 (primary node in the replica set)节点的挂钟时间。

replSetGetStatus.members[n].electionTime

操作日志中有关选举时间戳的信息(适用于当前主节点)。有关选举的更多信息,请参阅副本集高可用性

replSetGetStatus.members[n].electionDate

包含选举日期的 ISODate 格式的日期字符串(适用于当前主节点)。有关选举的更多信息,请参阅副本集高可用性

replSetGetStatus.members[n].lastHeartbeat

An 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 the date and lastHeartbeatRecv fields 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].lastHeartbeatRecv

An 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 the date and lastHeartbeat fields 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].lastHeartbeatMessage

When the last heartbeat included an extra message, the lastHeartbeatMessage contains a string representation of that message.

replSetGetStatus.members[n].pingMs

pingMs 表示往返数据包在远程成员和本地实例之间传输所需的毫秒 (ms) 数。

该值不会出现在返回 rs.status() 数据的节点中。

replSetGetStatus.members[n].syncSourceHost

The syncSourceHost field holds the hostname of the member from which this instance syncs.

If the replSetGetStatus.members[n] is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.members[n].syncSourceId

The syncSourceId field holds the replSetGetStatus.members[n]._id value of the syncSourceHost.

If the replSetGetStatus.members[n] is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.members[n].configVersion

configVersion 值是 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.tooStale

A boolean which indicates that a replica set member has fallen too far behind the primary's oplog and is stuck in the RECOVERING state. This field is only included in the replSetGetStatus output if its value is true.

有关 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版本新增。

给本页内容打分