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.