首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在mongodb中找不到与读取首选项匹配的主机

在mongodb中找不到与读取首选项匹配的主机
EN

Stack Overflow用户
提问于 2016-08-24 15:33:15
回答 2查看 12.4K关注 0票数 3

我在分片环境中的新数据库中创建了一个新集合。

当使用coll.insertMany(list)时,我得到了以下错误。

代码语言:javascript
运行
复制
Exception in thread "main" com.mongodb.MongoCommandException: 
Command failed with error 133: 'unable to target write op for collection dbname.collection:: caused by :: 
FailedToSatisfyReadPreference: Could not confirm non-existence of database "dbname" due to inability to query the config server primary :: caused by :: 
FailedToSatisfyReadPreference: could not find host matching read preference { mode: "primary" } for set csReplSet' on server ip:27017. 
The full response is { "ok" : 0, "code" : 133, "errmsg" : "unable to target write op for collection dbname.collection:: caused by :: 
FailedToSatisfyReadPreference: Could not confirm non-existence of database \"dbname\" due to inability to query the config server primary :: caused by :: 
FailedToSatisfyReadPreference: could not find host matching read preference { mode: \"primary\" } for set csReplSet" }
EN

回答 2

Stack Overflow用户

发布于 2016-08-24 16:24:43

看起来阅读偏好给你的终端带来了问题。

请阅读首选项并设置哪个更适合您的应用程序

https://docs.mongodb.com/manual/reference/read-preference/

如果您的问题与下面的jira中提到的问题相关,那么我们需要mongo版本3.3.11,而目前我们只有3.2.9 released

https://jira.mongodb.org/browse/SERVER-22620

票数 4
EN

Stack Overflow用户

发布于 2020-04-14 17:50:21

在您的情况下,有可能读取首选项成员在副本集中不可用,即主数据不可用。

出于一个或多个原因。

当新的主服务器获取服务器的elected.

  • Majority不可用而没有主服务器可用时的
  • 故障切换方案。

https://docs.mongodb.com/manual/tutorial/troubleshoot-sharded-clusters/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39117060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档