Deploy a replica set lab

hello , in deploying the replica set i configured the conf files correctly and ran all the three chid process successfully and also created the admin user in port 27001…but i try to connect to the primary node by
(mongo --host “m103-repl/192.168.103.100:27001” -u “m103-admin”
-p “m103-pass” --authenticationDatabase “admin” )

i get the error
connecting to: mongodb://192.168.103.100:27001/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m103-repl
2021-01-01T08:39:22.800+0000 I NETWORK [js] Starting new replica set monitor for m103-repl/192.168.103.100:27001
2021-01-01T08:39:27.833+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-01-01T08:39:27.833+0000 I NETWORK [js] Cannot reach any nodes for set m103-repl. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2021-01-01T08:39:33.339+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-01-01T08:39:33.339+0000 I NETWORK [js] Cannot reach any nodes for set m103-repl. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2021-01-01T08:39:38.843+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-01-01T08:39:38.843+0000 I NETWORK [js] Cannot reach any nodes for set m103-repl. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2021-01-01T08:39:38.844+0000 E QUERY [js] Error: connect failed to replica set m103-repl/192.168.103.100:27001 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed
i even tried to connect by using the node name m103 instead of using the ip address as its provided in the lecture notes…but still im getting the same error!

Are you using vagrant?
The IP 192.168.103.100 is valid only in vagrant env
You are suppose to use IDE for this course

From the error, it may be that the IP does not exist, or no mongod running in.

It’s best to use the IDE, but it’s ok to try locally (only for the sake of understanding) even if you have to desist after a while.

Trobleshoot

The LAN-IP is given to a computer by the DHCP server built-in to the router. This is a useful thing to know. Try to find the IP of that computer in the LAN. It will probably be of the form 192.168.xxx.yyy

If that PC is where you’re typing, there is no need of the LAN-IP, and should work:

mongo --host "m103-repl/localhost:27001" -u "m103-admin"
-p "m103-pass" --authenticationDatabase "admin"

Please, be aware that to pass the exercises, the exercise has to be solved on the IDE for the corresponding Lab, not your local instance.

could you please tell me which ip address or host i have to mention when i’m using the ide?
i’m not running it in local machine but i tried to use the node name “m103” provided in the lecture notes but still im getting the same error

no im not using vagrant…could you tell me which ip i have to use to run in ide?

The first step of the lab indicates:
There are three configuration files in your IDE workspace, but they are incomplete.

Update these configuration files so that all three mongod processes:

  • authenticate internally using the keyfile /var/mongodb/pki/m103-keyfile
  • belong to the replica set m103-repl

This means you are only supposed to alter the existing configuration file to add the above two items. This also means that the IP address, host and other configuration items already have the correct values. So do not modify them. If you did, reset the workspace and start from scratch.

yeah i did it and all the config files ran succesfully …i’m getting the error when i try to reconnect to primary node with authentication after creating the user as it was mentioned

Post a screenshot.

e1 e2 e3

The host name m103 is not a valid host name. You must connect using the value of the bindIp parameter specified in the configuration file.

What I would do (don’t be too certain), is:

  • To check the IP of the computer on the LAN just run ifconfig | grep inet

You’ll find the two possibilities:

  1. the loopback 127.0.0.1 aka localhost,

This is the same for everyone.

  1. the IP for the node on the ethernet lan example 10.81.176.6.

For Option 1

It should be enough to write the command I already posted to you:

For Option 2

mongo --host "m103-repl/<ReplaceWith_IP_FromGrep>:27001" -u "m103-admin"
-p "m103-pass" --authenticationDatabase "admin"

Also that IP needs to be added to the config file, bindIp.

Hi Shrikar,

I happened to solve that same Lab just two days before, had no issues. May I direct your attention to the 3 given conf files in the online IDE and therein you shall find just localhost for the bindIp entry, not 192.168.xxx.yyy. So, I did not dare use the latter.

Therefore, you might want to try mongo --host "m103-repl/localhost:27001" to reconnect within the IDE terminal.

By the way, did you double-check for a “successfully created” answer when you copy-pasted the given code for adding the m103-admin user against the admin database before?

Hope you can move forward, Regards, M.

yes sir , thats my mistake ! , i have’nt noticed the bind ip…
thank u so much

1 Like

yeah i got the acknowledgement of successfully created the user, it’s my mistake tat i unfortunately didnt noticed the bind ip…thank u so much !!

Glad to hear, you’re welcome! Regards, M.