我在分片环境中的新数据库中创建了一个新集合。
当使用coll.insertMany(list)
时,我得到了以下错误。
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" }
发布于 2016-08-24 16:24:43
看起来阅读偏好给你的终端带来了问题。
请阅读首选项并设置哪个更适合您的应用程序
https://docs.mongodb.com/manual/reference/read-preference/
如果您的问题与下面的jira中提到的问题相关,那么我们需要mongo版本3.3.11,而目前我们只有3.2.9 released。
发布于 2020-04-14 17:50:21
在您的情况下,有可能读取首选项成员在副本集中不可用,即主数据不可用。
出于一个或多个原因。
当新的主服务器获取服务器的elected.
https://docs.mongodb.com/manual/tutorial/troubleshoot-sharded-clusters/
https://stackoverflow.com/questions/39117060
复制相似问题