Everyone, greetings …
I am a new user of mongoDB, and I set up a laboratory to study and train the replication configuration (1 Master and 2 slaves)
The initial configuration and putting everything to work, despite having gone through some errors, I managed to complete and leave the entire replication structure between the members.
When I tried to delete a member and re-add it didn’t work.
To delete the member, I used the command rs.remove (“mongodb02: 27017”) on the master node. And on the mongodb02 node I stopped the mongodb service and then deleted all files in the mongo’s data folder.
To include mongodb02 again in the replication group I did the following: on the master node, I ran the command rs.add (“mongodb02: 27017”). And on the slave node is I started the mongodb service.
On the slave node (mongodb02) the files are recreated, however the member does not return for replication.
In rs.status () in master node, I have the following return
grp-replic-001:PRIMARY> rs.status()
{
"set" : "grp-replic-001",
"date" : ISODate("2020-09-18T21:14:06.597Z"),
"myState" : 1,
"term" : NumberLong(6),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 2,
"writeMajorityCount" : 2,
"votingMembersCount" : 3,
"writableVotingMembersCount" : 3,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"lastCommittedWallTime" : ISODate("2020-09-18T21:13:56.959Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"readConcernMajorityWallTime" : ISODate("2020-09-18T21:13:56.959 Z"),
"appliedOpTime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"durableOpTime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"lastAppliedWallTime" : ISODate("2020-09-18T21:13:56.959Z"),
"lastDurableWallTime" : ISODate("2020-09-18T21:13:56.959Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1600463596, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2020-09-18T20:34:20.457Z"),
"electionTerm" : NumberLong(6),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1600451358, 1),
"t" : NumberLong(5)
},
"numVotesNeeded" : 2,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2020-09-18T20:34:24.959Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2020-09-18T20:34:26. 581Z")
},
"members" : [
{
"_id" : 0,
"name" : "mongodb01:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 2874,
"optime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"optimeDate" : ISODate("2020-09-18T21:13:56Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1600461260, 1),
"electionDate" : ISODate("2020-09-18T20:34:20Z"),
"configVersion" : 3,
"configTerm" : 6,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 2,
"name" : "mongodb03:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 2395,
"optime" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"optimeDurable" : {
"ts" : Timestamp(1600463636, 1),
"t" : NumberLong(6)
},
"optimeDate" : ISODate("2020-09-18T21:13:56Z"),
"optimeDurableDate" : ISODate("2020-09-18T21:13:56Z"),
"lastHeartbeat" : ISODate("2020-09-18T21:14:05.430Z"),
"lastHeartbeatRecv" : ISODate("2020-09-18T21:14:06.250Z" ),
"pingMs" : NumberLong(1),
"lastHeartbeatMessage" : "",
"syncSourceHost" : "mongodb01:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 3,
"configTerm" : 6
},
{
"_id" : 3,
"name" : "mongodb02:27017",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDurable" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2020-09-18T21:14:06.037Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(2),
"lastHeartbeatMessage" : "Our replica set configuration is invalid or does not include us",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"configVersion" : -2,
"configTerm" : -1
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1600463636, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1600463636, 1)
}
But, rs.status() in node slave, I return
> rs.status()
{
"operationTime" : Timestamp(0, 0),
"ok" : 0,
"errmsg" : "Our replica set config is invalid or we are not a member of it",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig",
"$clusterTime" : {
"clusterTime" : Timestamp(1600463767, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
>
>
Could someone help me find where I’m going wrong?