Issue adding a new node to the replica set using hostname

Hi all, doing this lab I found some issues adding a new node to the replica set.

Everything works fine until I tried to add the “m103:27003” node to the rs. Then, I saw this error message in the mongo shell:

> MongoDB Enterprise m103-repl:PRIMARY> rs.isMaster()

{
“hosts” : [
“192.168.103.100:27001”,
“192.168.103.100:27002”,
“m103:27003”
],

2019-10-27T13:21:32.907+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 127.0.1.1:27003, in(checking socket for error after poll), reason: Connection refused
2019-10-27T13:22:02.912+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 127.0.1.1:27003, in(checking socket for error after poll), reason: Connection refused

I noted that the resolved IP address was the localhost instead of 192.168.103.100.

vagrant@m103:~$ ping m103
PING m103.mongodb.university (127.0.1.1) 56(84) bytes of data.
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=2 ttl=64 time=0.041 ms

Looking inside the host file I found this:

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

The m103 name was matching in the first line to the localhost address. So, I made a copy of the file (just in case to screw it up)

sudo cp /etc/hosts /etc/hosts.bkp

And after that, I edited the host file deleting the m103 name in the first line:

127.0.1.1 m103.mongodb.university m103

Inside the mongo shell, I tried to remove and add again the node:

rs.remove(“m103:27003”)
rs.add(“m103:27003”)

And now all works fine:

2019-10-27T13:32:21.588+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Socket closed remotely, no longer connected (idle 30 secs, remote host 192.168.103.100:27003)
2019-10-27T13:32:21.590+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to m103:27003 (1 connections now open to m103:27003 with a 5 second timeout)

I hope that this help someone having the same issue.

P.S: If you try to execute the verification script while the error is seen, the correction is right!, but don’t tell anybody. :slight_smile:

Good investigative work there @Federico_35069

This topic was recently discussed in this thread.

Long story short, to follow the lecture exactly, you should map the Domain Name to 192 instead of your localhost (127).

Hi @Federico_35069,

I’m glad your issue got resolved and you were able to map the hostname m103 to the IP address 192.168.103.100.

Additionally, I would also recommend you to map the hostname m103.mongodb.university to the IP address 192.168.103.100.

Hope it helps!

If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi @Shubham_Ranjan, the provision file isn’t mapping the full FQDN to the 192.168.103.100 IP. It’s instead mapping it to m103. Can you please fix for the next session or add some instructions in the lecture re this as this is causing a lot of problems? Here’s the faulty line in the provision file (ip_config()):
image

And the faulty bottom line in the host file:

All provisioned machines (including mine) are ending up with this faulty line.

Hi @007_jb,

Thanks for reporting this issue. We are looking into it and hopefully we would be able to resolve it at the earliest.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

What is faulty about it? Please explain. I have the same issue as reported by Federico_35069 in the beginning of the post.

Thanks.

Prasad.

P.S.: I found the solution was at the bottom of the question itself!

Hi @Prasad_45636,

We have fixed the issue and the changes will be pushed out soon.

If you are also having incorrect IP address and hostname mapping in your vagrant environment then please refer this post for modifying it.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer