开发者社区> 问答> 正文

mongo查询抛出异常,什么原因?

软件版本: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

展开
收起
落地花开啦 2016-02-26 17:27:24 15498 0
2 条回答
写回答
取消 提交回答
  • 阿里云高级技术专家

    OperationFailure: could not find host matching read preference { mode: "primary", tags: [ {} ] } for set rs1

    请确认下rs1这个副本集当前的primary是否正常

    2019-07-17 18:48:30
    赞同 展开评论 打赏
  • 喜欢技术,喜欢努力的人

    貌似是无法连接mongodb 的primary主服务器。

    2019-07-17 18:48:30
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载