Home > Software design >  "show dbs" fails on mongo shell
"show dbs" fails on mongo shell

Time:01-06

This is the first time I am trying to connect to this mongo instance, which is setup by my ex-colleague. when I run "show dbs", I have seen such message:

rs0:SECONDARY> show dbs
2022-01-05T18:33:11.282 0000 E  QUERY    [js] uncaught exception: Error: listDatabases failed:{
        "operationTime" : Timestamp(1641407590, 1),
        "ok" : 0,
        "errmsg" : "not master and slaveOk=false",
        "code" : 13435,
        "codeName" : "NotMasterNoSlaveOk",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1641407590, 1),
                "signature" : {
                        "hash" : BinData(0,"...="),
                        "keyId" : NumberLong("...")
                }
        }
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:135:19
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:87:12
shellHelper.show@src/mongo/shell/utils.js:906:13
shellHelper@src/mongo/shell/utils.js:790:15
@(shellhelp2):1:1
rs0:SECONDARY> 

Any ideas what could be wrong ?

Thanks,

Jack

Following is the screenshot How I got that failure.

enter image description here

CodePudding user response:

You need to execute:

   rs.slaveOk()

From the SECONDARY to allow show dbs after ...

  •  Tags:  
  • Related