mongo查询抛出的这个异常,各位大侠知道是啥原因吗

快乐鸟 发布于 2016/03/23 09:24
阅读 8K+
收藏 0

软件版本:python2.7,pymongo3.2 ,MongoDB3.2

错误信息:在用find_one方法查询时 data=db.find_one({'cid':tempDict['cid']}) ,抛出如下错, 查了好久也没查出原因。。。

File "build/bdist.linux-x86_64/egg/pymongo/collection.py", line 1006, in find_one
    for result in cursor.limit(-1):
  File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 1097, in next
    if len(self.__data) or self._refresh():
  File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 1019, in _refresh
    self.__read_concern))
  File "build/bdist.linux-x86_64/egg/pymongo/cursor.py", line 905, in __send_message
    helpers._check_command_response(doc['data'][0])
  File "build/bdist.linux-x86_64/egg/pymongo/helpers.py", line 196, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
OperationFailure: could not find host matching read preference { mode: "primary", tags: [ {} ] } for set rs1

加载中
0
快乐鸟
快乐鸟
自己顶下
0
Karblue
Karblue
貌似是无法连接mongodb 的primary主服务器。
0
Karblue
Karblue
primary

All read operations use only the current replica set primary[5] This is the default read mode. If the primary is unavailable, read operations produce an error or throw an exception.

看样子的确是这样. primary 服务器不可用。 read操作就会抛出异常。

详情见:https://docs.mongodb.org/manual/reference/read-preference/

Karblue
Karblue
回复 @快乐鸟 : 看看网络原因呢。表象上就是无法连上primary服务器了。为什么连不上原因就太多了。。
快乐鸟
快乐鸟
但不知道如何下手,我们的mongo是两台分片,难道并发量大,就出现连不上的情况,目前这种错只是偶尔出现
快乐鸟
快乐鸟
非常感谢Karblue,你的答复总算让我找到点头绪
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部