MongoDB副本集replica set(五)--故障排查

 

(一)查看副本集状态
要查看副本集状态及每个成员的状态,可以连接到主节点,使用 rs.status() 命令查看:

rstest:PRIMARY> rs.status()
{
"set" : "rstest",
"date" : ISODate("2020-06-30T15:06:44.586Z"),
"myState" : 1,
"term" : NumberLong(15),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 2,
"writeMajorityCount" : 2,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"lastCommittedWallTime" : ISODate("2020-06-30T15:06:38.972Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"readConcernMajorityWallTime" : ISODate("2020-06-30T15:06:38.972Z"),
"appliedOpTime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"durableOpTime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"lastAppliedWallTime" : ISODate("2020-06-30T15:06:38.972Z"),
"lastDurableWallTime" : ISODate("2020-06-30T15:06:38.972Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1593529578, 1),
"lastStableCheckpointTimestamp" : Timestamp(1593529578, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "priorityTakeover",
"lastElectionDate" : ISODate("2020-06-30T11:42:47.656Z"),
"electionTerm" : NumberLong(15),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(1593517366, 1),
"t" : NumberLong(14)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1593517366, 1),
"t" : NumberLong(14)
},
"numVotesNeeded" : 2,
"priorityAtElection" : 3,
"electionTimeoutMillis" : NumberLong(10000),
"priorPrimaryMemberId" : 2,
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2020-06-30T11:42:47.731Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2020-06-30T11:42:48.789Z")
},
"electionParticipantMetrics" : {
"votedForCandidate" : true,
"electionTerm" : NumberLong(14),
"lastVoteDate" : ISODate("2020-06-30T11:42:36.235Z"),
"electionCandidateMemberId" : 2,
"voteReason" : "",
"lastAppliedOpTimeAtElection" : {
"ts" : Timestamp(1593364745, 1),
"t" : NumberLong(12)
},
"maxAppliedOpTimeInSet" : {
"ts" : Timestamp(1593364745, 1),
"t" : NumberLong(12)
},
"priorityAtElection" : 3
},
"members" : [
{
"_id" : 0,
"name" : "192.168.10.41:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 12262,
"optime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"optimeDate" : ISODate("2020-06-30T15:06:38Z"),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1593517367, 1),
"electionDate" : ISODate("2020-06-30T11:42:47Z"),
"configVersion" : 12,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 2,
"name" : "192.168.10.43:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 12258,
"optime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"optimeDurable" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"optimeDate" : ISODate("2020-06-30T15:06:38Z"),
"optimeDurableDate" : ISODate("2020-06-30T15:06:38Z"),
"lastHeartbeat" : ISODate("2020-06-30T15:06:43.724Z"),
"lastHeartbeatRecv" : ISODate("2020-06-30T15:06:43.051Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncingTo" : "192.168.10.41:27017",
"syncSourceHost" : "192.168.10.41:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 12
},
{
"_id" : 3,
"name" : "192.168.10.42:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 12258,
"optime" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"optimeDurable" : {
"ts" : Timestamp(1593529598, 1),
"t" : NumberLong(15)
},
"optimeDate" : ISODate("2020-06-30T15:06:38Z"),
"optimeDurableDate" : ISODate("2020-06-30T15:06:38Z"),
"lastHeartbeat" : ISODate("2020-06-30T15:06:43.724Z"),
"lastHeartbeatRecv" : ISODate("2020-06-30T15:06:43.051Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncingTo" : "192.168.10.43:27017",
"syncSourceHost" : "192.168.10.43:27017",
"syncSourceId" : 2,
"infoMessage" : "",
"configVersion" : 12
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1593529598, 1),
"signature" : {
"hash" : BinData(0,"JcYryJc0DU0GgX0mCKS1D86r30Y="),
"keyId" : NumberLong("6841443127941660675")
}
},
"operationTime" : Timestamp(1593529598, 1)
}
View Code

相关文章: