Hello Everyone, At first, Thank you all for helping in this forum during the past few weeks,
Second I have an issue regarding my replica set and I hope to understand and fix it.
I have a 3 nodes replica set ( 3 Devices in the same network )
1 Primary (Priority 1) MONGO-PC1:27017
1 Secondary (Priority 0.5) MONGO-PC2:27017
1 Arbiter (Priority 0) MONGO-PC3:27017
Note: Before I adding the arbiter node I write the following command:
db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 1
}
})
And the following to adjust Priority of the secondary node:
cfg = rs.config()
cfg.members[1].priority = 0.5
rs.reconfig(cfg)
rs.stepDown()
Now When The arbiter node and The Secondary node are goes down for maintenance, the Primary node changes to Secondary status and no way to go primary again without the Arbiter node & My question is: how to make the primary node to still primary even the arbiter & secondary goes down. I think it may be something related with WriteConcern or Priority or Votes as I did not get the concept of it yet.
Rs.Status();
{
"set" : "reps0",
"date" : ISODate("2023-04-14T03:06:49.245Z"),
"myState" : 1,
"term" : NumberLong(37),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 2,
"writeMajorityCount" : 2,
"votingMembersCount" : 3,
"writableVotingMembersCount" : 2,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"lastCommittedWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"appliedOpTime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"durableOpTime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"lastAppliedWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"lastDurableWallTime" : ISODate("2023-04-14T03:06:44.455Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1681441554, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "priorityTakeover",
"lastElectionDate" : ISODate("2023-04-14T01:07:43.324Z"),
"electionTerm" : NumberLong(37),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(1681434458, 1),
"t" : NumberLong(36)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1681434458, 1),
"t" : NumberLong(36)
},
"numVotesNeeded" : 2,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"priorPrimaryMemberId" : 1,
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2023-04-14T01:07:43.589Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2023-04-14T01:07:44.485Z")
},
"members" : [
{
"_id" : 0,
"name" : "MONGO-PC1:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 7163,
"optime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"optimeDate" : ISODate("2023-04-14T03:06:44Z"),
"lastAppliedWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"lastDurableWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1681434463, 1),
"electionDate" : ISODate("2023-04-14T01:07:43Z"),
"configVersion" : 8,
"configTerm" : 37,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 1,
"name" : "MONGO-PC2:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 7157,
"optime" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"optimeDurable" : {
"ts" : Timestamp(1681441604, 1),
"t" : NumberLong(37)
},
"optimeDate" : ISODate("2023-04-14T03:06:44Z"),
"optimeDurableDate" : ISODate("2023-04-14T03:06:44Z"),
"lastAppliedWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"lastDurableWallTime" : ISODate("2023-04-14T03:06:44.455Z"),
"lastHeartbeat" : ISODate("2023-04-14T03:06:48.888Z"),
"lastHeartbeatRecv" : ISODate("2023-04-14T03:06:48.160Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncSourceHost" : "MONGO-PC1:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 8,
"configTerm" : 37
},
{
"_id" : 2,
"name" : "MONGO-PC3:27017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 7157,
"lastHeartbeat" : ISODate("2023-04-14T03:06:48.863Z"),
"lastHeartbeatRecv" : ISODate("2023-04-14T03:06:48.711Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"configVersion" : 8,
"configTerm" : 37
}
],
"ok" : 1,
"operationTime" : Timestamp(1681441604, 1)
}
Rs.conf():
{
"_id" : "reps0",
"version" : 8,
"term" : 37,
"members" : [
{
"_id" : 0,
"host" : "MONGO-PC1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "MONGO-PC2:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 0.5,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "MONGO-PC3:27017",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 0,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
}
],
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : -1,
"catchUpTakeoverDelayMillis" : 30000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("64559d997743r6d2t0a36aez")
}
}
Thanks for helping