Not able to add a server to the replica set

I’m getting an error when I add a server to the replica set using the command “rs.add(“m103.mongodb.university:27012”)”. I have confirmed that this server is running. The command I entered and full error message is:

MongoDB Enterprise m103-example:PRIMARY> rs.add(“m103.mongodb.university:27012”)
{
“ok” : 0,
“errmsg” : “Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 192.168.103.100:27011; the following nodes did not respond affirmatively: m103.mongodb.university:27012 failed with Connection refused”,
“code” : 74,
“codeName” : “NodeNotFound”,
“operationTime” : Timestamp(1566832150, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1566832150, 1),
“signature” : {
“hash” : BinData(0,“9eRFkX78X+7BJrHkqjDt3gAErJA=”),
“keyId” : NumberLong(“6729488375805378562”)
}
}
}

Please advise…

Dave

1 Like

HI @David_55636,

Please take a look at the following thread for reference and let me know if you still face any issues.

Thanks,
Muskan
Curriculum Support Engineer

There is no solutions in the mentioned thread

Hi,

Please confirm on the below two points:

  • you have initiated the replica set using rs.initiate()
  • the host name passed in rs.add() is correct - check the /etc/hosts file for the value of “m103.mongodb.university” which should point to “192.168.103.100”

If both the above are already in place and you still face the issue, please post the output of rs.status
and we’ll look into it further.

Thanks,
Muskan
Curriculum Support Engineer

Hi same error here

{
“set” : “m103-example”,
“date” : ISODate(“2019-11-20T18:13:46.332Z”),
“myState” : 1,
“term” : NumberLong(3),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“heartbeatIntervalMillis” : NumberLong(2000),
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(1574273619, 1),
“t” : NumberLong(3)
},
“readConcernMajorityOpTime” : {
“ts” : Timestamp(1574273619, 1),
“t” : NumberLong(3)
},
“appliedOpTime” : {
“ts” : Timestamp(1574273619, 1),
“t” : NumberLong(3)
},
“durableOpTime” : {
“ts” : Timestamp(1574273619, 1),
“t” : NumberLong(3)
}
},
“members” : [
{
“_id” : 0,
“name” : “192.168.103.100:27011”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 102,
“optime” : {
“ts” : Timestamp(1574273619, 1),
“t” : NumberLong(3)
},
“optimeDate” : ISODate(“2019-11-20T18:13:39Z”),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “could not find member to sync from”,
“electionTime” : Timestamp(1574273527, 1),
“electionDate” : ISODate(“2019-11-20T18:12:07Z”),
“configVersion” : 1,
“self” : true,
“lastHeartbeatMessage” : “”
}
],
“ok” : 1,
“operationTime” : Timestamp(1574273619, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1574273619, 1),
“signature” : {
“hash” : BinData(0,“FWPYJtSFIWNmmXITnagex5v23kQ=”),
“keyId” : NumberLong(“6761445037021593602”)
}
}
}

@Damiano_49342 this occurs when mongod cannot find the node you’re trying to add based on the host:port supplied. In your case, it cannot find m103.mongodb.university:27012.

You’ll notice that you started all the mongod processes using the IP address instead of the fully qualified domain name. You can verify this by using this Linux shell command:
ps -ef | grep "[m]ongo"

I’m guessing you can see three mongod process running and if that’s the case, you have three options:

  • Use the IP address instead of m103.mongodb.university
    rs.add("192.168.103.100:27012")
  • Use m103 instead of m103.mongodb.university
    rs.add("m103:27012")
  • Fix the hosts file by mapping m103.mongodb.university to 192.168.103.100 and you’ll be able to add it using the fully qualified domain name rs.add("m103.mongodb.university:27012")
    See this post:
    Could not add the replica set to the primary

Hey guys (@Muskan_47318, @Shubham_Ranjan), this has crept up again. Have you guys not added a note to the lectures yet?

1 Like

Hi @Damiano_49342,

I hope you found the post #6 from @007_jb helpful.

In addition to that I would request you to run this command and share the content of the file that you see on your screen.

sudo vim /etc/hosts

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Tried all of these options, but it is not working.
at the contrary the following labs are working fine and I could create the repl. set
no idea how come it is not good with those IPs

Hi @Damiano_49342,

I don’t have any visibility in how you are doing it. Can you please share the command that you are using to add a node to your replica set and the error message that you are getting ?

Also, please make sure that the node that you are trying to add is up and running.

Share this information as well :arrow_up:.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Any response re this?

Hi @007_jb,

We are looking into the issue and very soon we will decide the course of action for this.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

In the meantime, can’t you guys add a note/addendum to the lectures? I’ve seen it done in some of your lectures.

This worked for me, thanks @007_jb! They should change that in the instructions!

You’re welcome! Yes, it’s been mentioned on several occasions.

Hi @007_jb and @naeemgitonga,

We have fixed the issue and the changes that we have made would be visible in the future offerings very soon.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

this works!

for future reference, The contents of my hosts file(I didn’t edit) is below.

vagrant@m103:~$ more /etc/hosts
127.0.1.1	m103.mongodb.university	m103
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1       localhost localhost.localdomain localhost6 localhost6.localdomain6
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
192.168.103.100    m103 m103

Hi @ys_70859,

Thanks for sharing the information. We are aware of the issue and has made the necessary changes in our codebase. The changes would be reflected very soon.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

This worked for me, thank you very much! :wink:

You’re welcome @Vinny.Tells.22 :wink: :+1:

1 Like