M103 rs.add("localhost:27002") not working for lab

rs.add(“localhost:27002”) gives error for me at new environment of testing at Mongo University lab
“errmsg” : “Our set name did not match that of localhost:27003”,
“code” : 103,
“codeName” : “NewReplicaSetConfigurationIncompatible”,

The most likely cause is that you misspelled the replica set name in one of the configuration file.

Hi @ashwani_fzd,

This :point_down:

As I can see, you listed three different replica names in all the three configuration files.

~ Shubham

Hi Shubham,
Thanks I got point where given different replica set name for all three configuration.
It resolve rs.add(“localhost:27002”) addition.
–Passed cases 12 total, 11 passed, 0 skipped:
[FAIL] “The replica set ‘m103-repl’ contains localhost:27003”
Did you add ‘localhost:27003’ to the replica set ‘m103-repl’?
May I know why this getting failed, either for third config file port needs to be change because all three replica-set at same machine?

Which port did you use to start the 3rd mongod?

But yes, the 3rd config file port needs to be changed it has to match the port number given to rs.add and must match the lab requirements.

Hi @ashwani_fzd,

In addition to @steevej-1495,

Connect to the replica set and share the output of the following commands :

rs.conf()

rs.status()

~ Shubham

Hi Shubham,
I did same exercise again and it passed, but yes no change in config and commands which i executed at testing lab.
12 total, 12 passed, 0 skipped:
[PASS] “localhost:27001 is running”
[PASS] “localhost:27002 is running”
[PASS] “localhost:27003 is running”
[PASS] “Replication is enabled on localhost:27001”
[PASS] “Replication is enabled on localhost:27002”
[PASS] “Replication is enabled on localhost:27003”
[PASS] “Replica set ‘m103-repl’ has the correct name”
[PASS] “The replica set ‘m103-repl’ contains localhost:27001”
[PASS] “The replica set ‘m103-repl’ contains localhost:27002”
[PASS] “The replica set ‘m103-repl’ contains localhost:27003”
[PASS] “The replica set enforces client authentication”
[PASS] “The replica set m103-repl uses keyfile authentication”
Thanks, for help !

Hi @ashwani_fzd,

That’s strange. Let me know if you face any other issue. I will try to investigate this issue from my end.

~ Shubham

This is a complete mess.
My instrucctions
mongod -f mongod_1.conf
mongo --port 27001

rs.initiate()
use admin

db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

mongod -f mongod_2.conf
mongod -f mongod_3.conf
mongo --host “m103-repl/localhost:27001” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

rs.status()
rs.add(“m103-repl/localhost:27002”) – Not work
rs.add(“m103-repl/localhost:27003”)-- Not work

rs.add(“localhost:27002”) – Not work
rs.add(“localhost:27003”) – Not work

rs.add(“m103-repl:27002”) – Not work
rs.add(“m103-repl:27003”) – Not work

mongod_1.conf
storage:
dbPath: /var/mongodb/db/1
net:
bindIp: localhost
port: 27001
security:
authorization: enabled
systemLog:
destination: file
path: /var/mongodb/logs/mongod1.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

mongod_2.conf
storage:
dbPath: /var/mongodb/db/2
net:
bindIp: localhost
port: 27002
security:
authorization: enabled
systemLog:
destination: file
path: /var/mongodb/logs/mongod2.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

mongod_3.conf
storage:
dbPath: /var/mongodb/db/3
net:
bindIp: localhost
port: 27003
security:
authorization: enabled
systemLog:
destination: file
path: /var/mongodb/logs/mongod3.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

Sometimes it accepts node 2 although it gives an error and others 3.
“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”,

Please double check your config file
I don’t see security param with keyfile for internal member authentication
That could be the reason you are unable to add other nodes
Also show outputs of rs.conf() and rs.status()
Check mongod.log of each node for additional errors

1 Like

It works, my fault. Thanks!

1 Like

Hi @Felipe_Fernandez,

We are glad that @Ramachandra_Tummala’s response was helpful and you were able to find the solutions.
You can also refer to the docs for a better understanding if you want.

Regards,
Kushagra