奇怪的mongodb和mongoose错误:不是master和slaveOk = false错误 [英] strange mongodb and mongoose error: not master and slaveOk=false error
问题描述
我的node.js应用出现一个奇怪的错误
I'm getting a strange error in my node.js app
not master and slaveOk=false code 13435
我正在使用mongoose 4.0.2和mongodb 3.0.1进行findOne查询.该查询今天早些时候工作.
I'm doing a findOne query using mongoose 4.0.2 hitting a mongodb 3.0.1. The query was working earlier today.
这是什么错误?我正在按照每GB计划的标准在mongohq上运行.
What is this error? I'm running on mongohq on their standard per gb plan.
推荐答案
这意味着您试图从副本集中的辅助节点读取,默认情况下只能从主节点读取.
That means you're trying to read from a secondary node in a replica set, you can only read from the primary node by default.
您可以通过在连接到该辅助节点的mongo shell中运行rs.slaveOk()
来允许辅助节点接受读取.不建议允许从辅助节点读取数据,因为如果该节点尚未与主节点同步,则可能正在读取旧数据.
You can allow a secondary node to accept reads by running rs.slaveOk()
in a mongo shell that is connected to that secondary node. Allowing reads from a secondary is not recommended, because you could be reading stale data if the node isn't yet synced with the primary node.
这篇关于奇怪的mongodb和mongoose错误:不是master和slaveOk = false错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!