Unable to add the other replica set nodes into primary

Hi ,
as part of Lab: Deploy a Replica Set ,I have created all the config files with extra parameters as below.

security:

  • authorization: enabled*
  • keyFile: /var/mongodb/pki/m103-keyfile*
    replication:
  • replSetName: “m103-repl”*

Then i initiated a mongo process from config file 1 using
mongo --port 27001

switched to admin db and created a new user m103-repl
opened a parallel terminal window and created the other two config files and started their mongo process using mongo --port 27002,mongo --port 27003

in terminal 1 i switched to m103-admin from admin

rs.status() output as below

m103-repl:PRIMARY> use m103-admin
switched to db m103-admin
m103-repl:PRIMARY> rs.status()
{
“operationTime” : Timestamp(1648016317, 1),
“ok” : 0,
“errmsg” : “command replSetGetStatus requires authentication”,
“code” : 13,
“codeName” : “Unauthorized”,
“$clusterTime” : {
“clusterTime” : Timestamp(1648016317, 1),
“signature” : {
“hash” : BinData(0,“lGqopBSGrL+SFX60dWtP6WF9smU=”),
“keyId” : NumberLong(“7078173779607683073”)

now when i execute rs.add( “localhost:27002”)

etErrorWithCode@src/mongo/shell/utils.js:25:13
DBQuery.prototype.count@src/mongo/shell/query.js:383:11
DBCollection.prototype.count@src/mongo/shell/collection.js:1431:12
rs.add@src/mongo/shell/utils.js:1399:

now when i execute rs.add( “localhost:27003” )

hence the other two nodes are not getting added

and the o/p of rs.status again as below.

rs.status()
{
“operationTime” : Timestamp(1648016507, 1),
“ok” : 0,
“errmsg” : “command replSetGetStatus requires authentication”,
“code” : 13,
“codeName” : “Unauthorized”,
“$clusterTime” : {
“clusterTime” : Timestamp(1648016507, 1),
“signature” : {
“hash” : BinData(0,“lsr/s19Uz+0KZfKuC4F9DjIF9Xk=”),
“keyId” : NumberLong(“7078173779607683073”)
}
}
}
m103-repl:PRIMARY>

what am i missing here

1 Like

Please check your steps again
M103-repl is not a username but looks like you created an user by this name
You should not switch to m103-admin
m103-admin is not a DB.It is username

1 Like

Hi @Ramachandra_Tummala ,

Thanks for your response.

Based on your comments ,

M103-repl is not a username but looks like you created an user by this name-sorry for the typo ,as suggested in the exercise i have created the user m103-admin.

m103-admin is not a DB.It is username:yes ,so should i connect to this using connect command rather using use m103-admin

1 Like

Yes connect with user
Use DB is to switch to another db

1 Like

Hi @Ramachandra_Tummala ,

Thanks for your response .It worked now