7

I'm trying to add a node to a replica set using rs.add("developer-ViratualBox:30103") and I'm getting the following error message:

{
"ok" : 0,
"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: developer-VirtualBox:30101; the following nodes did not respond affirmatively: developer-ViratualBox:30103 failed with Failed attempt to connect to developer-ViratualBox:30103; couldn't initialize connection to host developer-ViratualBox, address is invalid",
"code" : 74
}

The node is already running and I'm connected to it using mongo shell. What could possibly be the problem?

Ahmad Hosny
  • 597
  • 1
  • 6
  • 23

7 Answers7

4

The actual error is couldn't initialize connection to host developer-ViratualBox, address is invalid, Simply the primary node is not able to connect with secondery nodes. check connections, firewall, and check connection with mongo shell whether you can access that port or not.

Laxmikant Dange
  • 7,606
  • 6
  • 40
  • 65
1

The missing point is that the instance that I was trying to add did not have mongod instance started at the port defined. The given connection parameters hence were incorrect, and that caused the communication problem.

Ahmad Hosny
  • 597
  • 1
  • 6
  • 23
1

While starting secondary mongod process use --replSet option the try to run rs.add("localhost:27002") from primary mongod shell.

Raju Lalli
  • 11
  • 1
1

While creating rsconf file please enter <localhost:port> instead of <hostname:port>. And then reconfig(rsconf).

example :

rs0:PRIMARY>     
rsconf = {
             _id: "rs0",
             members: [
                 {
                     _id: 0,
                     host: "**localhost**:port for primary rs"
                 }]
         }

rs0:PRIMARY> rs.initiate(rsconf)
    {
        "info" : "try querying local.system.replset to see current configuration",
        "ok" : 0,
        "errmsg" : "already initialized",
        "code" : 23
    }

If you are getting above error then use the below command:

rs0:PRIMARY> rs.reconfig(rsconf)

Adding secondary node : rs.add("localhost:port for secondary rs")

Hope it will work.

0

You can only add members while connected to the primary. To know which member is the primary, log into any member of the replica set and issue the db.isMaster() command.

Then, use rs.add() to add the new member to the replica set. For example, to add a member at host mongodb3.example.net, issue the following command:

rs.add("developer-ViratualBox:30103")
vmr
  • 1,895
  • 13
  • 24
0

Another possible issue is that the machine that you are trying to add to the replica set is not configured to run with replication. Adding this entry to the mongod.conf on the machine that you're trying to add and restarting the service worked for me:

replication:
  replSetName: evoReplicaSet
Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59
-3

you should use docker network to solve this problem.