Lab - Remove and Re-Add a Node problem

Hi all,

I write this post for asking what I have to do in this Lab, because I dont understand well what I have to do. I removed my third node, but then I dont know what I should change. What means exactly this part of the text?:

""In this lab, you will modify the replica set so one of the nodes uses the hostname m103, the virtual machine hostname, instead of the external IP address of the Vagrant box.

To correctly reconfigure this node, you will have to remove the node from the replica set, and then add it back with the correct hostname. For this lab, you only need to do this for one of the nodes in the set.""

Please help me!! Thanks you :smiley:

While logged into the Primary node, you need to remove one of the secondary nodes with rs.remove(), and then simply re-add it with rs.add(), only instead of using the ip address 192.168.103.100 you use m103. Hope this helps!

2 Likes

Thanks you so much, I got it! However I have a question:
when I wrote:

–host m103-repl/m103.mongodb.university:27001

The connection to the server fail. I have to replace “m103-repl/m103.mongodb.university:27001” for “m103-repl/192.168.103.100:27001”.

I would like to know why this does not run for me.
Thanks you so much!!

The host name m103.mongodb.university probably do not resolve to the IP address 192.168.103.100.

The command ping m103.mongodb.university may tells you the IP address if any. You may correct it in the file /etc/hosts.

1 Like

Well, I realised that the IP adress is wrong. Do you know how it should be changed?
Thanks you so much!! :smiley:

The file /etc/hosts should be edited. Make sure you sudo to edit the file as it is only writable by root. Personally I use vi so I edit with sudo vi /etc/hosts.

1 Like

This was exactly what I was needing. I rewrote my config files before I realize it was that simple.

2 Likes

can you explain me clearly .
why we need hosts file??

can u tell me how to set ip for m103

We had to do it when I took the course a while back. Not sure if it is needed anymore, you should start a new thread.

in this lab , i added new replica set using rs.add(“m103:27003”) but show error like this .

if i replace m103 with ip address its works fine.

my question is , do u have set ip address for m103 . if it so , how to set ??

Hi @Dhilip_28128,

The m103 hostname maps to ip address 192.168.103.100, you can check the same using the command below:

ping m103

Otherwise, you can check the /etc/hosts file to view the hostname mapping.

Please let me know, if you have any questions. I would recommend you to share the screenshot of the error, the above ping command and contents of /etc/hosts file in a separate thread to avoid confusion.

Thanks,
Sonali


in this lab , i added new replica set using rs.add(“m103:27003”) but show error like this .

if i replace m103 with ip address its works fine.

how to complete this task

It looks like m103 is IP 127.0.1.1 and it might be why it fails. It depends on how you started the serer at port 27001. If you started it with 127.0.0.1 it will fails because it does not listen to 127.0.1.1.

it shows same error

Like I wrote your server (now at port 27003) is not listening at IP 127.0.1.1. It might be listening at 127.0.0.1 or 192.168.103.100. You have to listen to the same IP/port as the one you try to talk. If you start your server at 127.0.0.1:27003 then you must connect to 127.0.0.1:27003 but if you start it at 127.0.1.1:27003 you must connect to 127.0.1.1:27003. Same IP and same port number.

Hi @Dhilip_28128,

As per lab requirements, all the nodes should be configured with IP address: 192.168.103.100 .
You will need to update the /etc/hosts file and map m103 with the 192.168.103.100 IP address.
Please check the screenshot of my /etc/hosts file:

Please let me know, if you have any questions.

Thanks,
Sonali

@Dhilip_28128,

Like @steevej-1495 and @Sonali_Mamgain have explained, the problem is with the mapping of m103 to 192.168.103.100 in your /etc/hosts file and you need to edit it as follows:

  • Delete (1.)
  • Change (2.) like this:
    image
  • Save and exit the file

@Sonali_Mamgain, for some strange reason this is still happening. As explained here, here and here, the hosts file isn’t mapping correctly and somehow a 127.0.1.1 IP mapping is created exactly like my screenshot. Can you please pass on to your colleagues to investigate fix and in the meantime please add a note to the lectures/labs to avoid any confusion in the future. It will continue to creep up.

PS: This particular lab actually requires using the hostname instead of the IP address

2 Likes

thank you so much for your response .
i had overcome this error

Closing the thread as the issue has been resolved.