count failed: not master{ "note" : "from execCommand", "ok" : 0, "

Posted @SkySea

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了count failed: not master{ "note" : "from execCommand", "ok" : 0, "相关的知识,希望对你有一定的参考价值。

count failed: not master{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" } at src/mongo/shell/query.js:191

在SECONDARY节点无法show dbs

主从启动之后,连接slave可以成功连上,但是在slave中执行 show dbs 的时候就报错了:

QUERY Error: listDatabases failed:{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
解决方法:

在报错的slave机器上执行 rs.slaveOk()方法即可。

解释一下具体slaveOk方法是什么意思?

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.

以上是关于count failed: not master{ "note" : "from execCommand", "ok" : 0, "的主要内容,如果未能解决你的问题,请参考以下文章

Failed to complete obtain psql count Master gp_segment_configuration Script Exiti

06-Vue报错Failed to execute 'setAttribute' on 'Element': '{{count}}' is not a

error: src refspec master does not match any error: failed to push some refs to ‘github.com:Lydever/

error: src refspec master does not match any error: failed to push some refs to ‘github.com:Lydever/

MySQL 跨版本主从复制时报错:ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.

fatal: Authentication failed could not read from remote repository