Hi fellows,
I build a replication set of three nodes om ports 27011 27012 and 27013. if I run
db.serverStatus()[‘repl’] I get no response neither on the master node1 nor the default mongo on port 27017 but
db.serverStatus() shows me
{
*** “ok” : 0,***
*** “errmsg” : “command serverStatus requires authentication”,***
*** “code” : 13,***
*** “codeName” : “Unauthorized”,***
*** “$clusterTime” : {***
*** “clusterTime” : Timestamp(1657802463, 1),***
*** “signature” : {***
*** “hash” : BinData(0,“eNE3SoG72nibCQq+fImaox4jGhQ=”),***
*** “keyId” : NumberLong(“7119783323987083266”)***
*** }***
*** },***
*** “operationTime” : Timestamp(1657802463, 1)***
on node1
and
{
*** “ok” : 0,***
*** “errmsg” : “command serverStatus requires authentication”,***
*** “code” : 13,***
*** “codeName” : “Unauthorized”***
}
on the default mongo on port 27017
Why does this
db.serverStatus()[‘repl’]
not show any response?
Thanks in advance,
Uli
Hi
there is a response
*** “errmsg” : “command serverStatus requires authentication”,***
*** “code” : 13,***
*** “codeName” : “Unauthorized”***
you need to authenticate yourself
2 Likes
Hi Arek,
Thanks fpor your reply. How do I authenticate myself using the
db.serverStatus()[‘repl’]
command?
Regards,
Uli
you need to authenticate yourself when you are connecting to mongo instance - for example via mongosh ,
mongosh --port 27017 --authenticationDatabase "admin" -u "user" -p "password"
or
mongosh --port 27017
use admin
db.auth("myUserAdmin", passwordPrompt()) // or cleartext password
once you authenticate yourself successfully you can use
db.serverStatus()
1 Like
Ulrich_Kleemann1:
27011 27012 and 27013
in addition to @Arkadiusz_Borucki 's answer above on how you connect with credentials, you are connecting to the wrong server.
the server on 27017 seems to be a single node default server running with the default config file. This server is not a part of your replica set.
You need to use --host
and --port
flags for your replica set servers, where ports are the ones I quoted. if all 3 runs on your local machine, you don’t need to supply host IP, else you will need that too.
1 Like