Mongo Slave节点无法show dbs - 代码日志

Mongo Slave节点无法show dbs

https://wuyanteng.github.io/2018/07/09/Mongo-Slave%E8%8A%82%E7%82%B9%E6%97%A0%E6%B3%95show-dbs/

在SECONDARY节点无法show dbs

主从启动之后,连接slave可以成功连上,但是在slave中执行 show dbs 的时候就报错了:QUERY  Error: listDatabases failed:{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }

解决方法

在报错的slave机器上执行 rs.slaveOk()  再执行show dbs即可

官网解释

Provides a shorthand for the following operation:db.getMongo().setSlaveOk()This allows the current connection to allow read operations to run on secondary members. See the readPref() method for more fine-grained control over read preference in the mongo shell.

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:Mongo Slave节点无法show dbs