Replica set set-up : host unreachable

Hi, I am getting the following error in my log file when i try and add the nodes to my replicaset

rs.add(“m103.mongodb.university:27013”)

I am not understanding why. I have created all 3 node#.conf files and changed their permissions to 400 and created the keyfile and also made 400 permission

2018-10-28T15:49:23.305+0000 I REPL [conn5] replSetReconfig admin command received from client; new config: { _id: “m103-example”, version: 2, protocolVersion: 1, members: [ { _id: 0, host: “192.168.103.100:27011”, arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1.0, host: “m103.mongodb.university:27013” } ], settings: { chainingAllowed: true, heartbeatIntervalMillis: 2000, heartbeatTimeoutSecs: 10, electionTimeoutMillis: 10000, catchUpTimeoutMillis: -1, catchUpTakeoverDelayMillis: 30000, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 }, replicaSetId: ObjectId(‘5bd5d7af13f6a719eb0d7895’) } }
2018-10-28T15:49:23.312+0000 I NETWORK [conn5] getaddrinfo(“m103.mongodb.university”) failed: Name or service not known
2018-10-28T15:49:23.312+0000 I REPL [conn5] replSetReconfig config object with 2 members parses ok
2018-10-28T15:49:23.312+0000 I ASIO [NetworkInterfaceASIO-Replication-0] Connecting to m103.mongodb.university:27013
2018-10-28T15:49:23.317+0000 I ASIO [NetworkInterfaceASIO-Replication-0] Failed to connect to m103.mongodb.university:27013 - HostUnreachable: HostUnreachable
2018-10-28T15:49:23.317+0000 I ASIO [NetworkInterfaceASIO-Replication-0] Dropping all pooled connections to m103.mongodb.university:27013 due to failed operation on a connection
2018-10-28T15:49:23.317+0000 W REPL [replexec-1] Failed to complete heartbeat request to m103.mongodb.university:27013; HostUnreachable: HostUnreachable
2018-10-28T15:49:23.317+0000 E REPL [conn5] replSetReconfig failed; NodeNotFound: 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:27013 failed with HostUnreachable

1 Like

Fix found from:

From your vagrant machine, do the following:

     vagrant@m103:~$  sudo vi /etc/hosts
  • Go in insert mode by pressing i .
  • Edit the file’s first line, make it 127.0.0.1 instead of 127.0.1.1, it should look something like this:
 127.0.0.1       m103.mongodb.university m103
  • Save the file by pressing Esc and then press :wq . It will exit the editor and you will be back on command line.
  • Check by pinging m103 again.
 vagrant@m103:~$ ping m103
 PING m103.mongodb.university (127.0.0.1) 56(84) bytes of data.

It looks like my hostname is not m103.mongodb.university but just m103. I adjusted this in my rs.add() and now it works fine

3 Likes

solved my problem. thanks

1 Like