Lab: Deploy a Replica Set

I am having specific trouble with this lab. I have tried resetting the terminal three times and I keep getting the same error. It has to do with the rs.add() command. I can set up the config file as follows:

dbPath: /var/mongodb/db/3
bindIp: localhost
port: 27003
authorization: enabled
destination: file
path: /var/mongodb/logs/mongod3.log
logAppend: true
fork: true
replSetName: m103-repl

This is repeated in 1 and 2. I can create the directories as follows
mkdir -p /var/mongodb/db/1…2…3

I then log into One instance and run rs.initiate() and get to the primary prompt.

I create a user

I log out and log back in using mongo --port 27001 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

This logs me in using the user that I created… Here is when the problem starts. I am suppose to run rs.add() but in the lecture it shows m103…

I tried rs.add (“m103-repl.localhost:27002”) but it errors out

m103-repl:PRIMARY> rs.add(“m103-repl.localhost:27002”)
“operationTime” : Timestamp(1605415949, 1),
“ok” : 0,
“errmsg” : “Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2”,
“code” : 103,
“codeName” : “NewReplicaSetConfigurationIncompatible”,
“$clusterTime” : {
“clusterTime” : Timestamp(1605415949, 1),
“signature” : {
“hash” : BinData(0,“8HFFUfWNUEUeM8MA4O9URb6FMGY=”),
“keyId” : NumberLong(“6895205776206331905”)

What am I missing???

Answered my own problem. Make sure you are authenticating!!! I missed the addition of the keyFile line.

1 Like

Hi @David_Thompson,

I’m glad your issue got resolved :slight_smile: . Please feel free to create a new thread if you face any other difficulty.

~ Shubham