您的位置:首页 > 数据库 > Mongodb

mongoDB Error:not master and slaveOk=false

2017-03-08 00:00 1676 查看
摘要: { "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435 }

今天在使用mongoDB时,使用以下命令,想看一下集合的时候:

SECONDARY> show collections

报了下面的错:

2017-03-08T17:15:31.037+0800 E QUERY    [thread1] Error: listCollections failed: { "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435 } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype._getCollectionInfosCommand@src/mongo/shell/db.js:773:1
DB.prototype.getCollectionInfos@src/mongo/shell/db.js:785:19
DB.prototype.getCollectionNames@src/mongo/shell/db.js:796:16
shellHelper.show@src/mongo/shell/utils.js:754:9
shellHelper@src/mongo/shell/utils.js:651:15
@(shellhelp2):1:1

重点是这句:

"errmsg" : "not master and slaveOk=false"

拿去百度了一下,发现这是一个正常的情况,由于读写分离,SECONDARY不允许读写的,所以会报这个ERROR。

如果偏要解决的话,执行下面的命令:

SECONDARY> rs.slaveOk();

OK~~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MongoDB