FailedToSatisfyReadPreference:找不到与读取首选项匹配的主机{模式:“ primary”}

问题描述 投票:0回答:1

我想在项目中使用mongodb-shard。我创建了一个舵图https://github.com/b-rohit/mongodb-shard-chart来部署到kubernetes集群。

我使用本地运行的kind群集进行测试。配置和分片服务器运行正常。我能够在他们的mongo shell中执行命令。 mongos服务器无法连接到配置服务器中设置的副本。我在mongos中收到以下错误消息

2020-04-17T13:33:31.579+0000 W  SHARDING [replSetDistLockPinger] pinging failed for distributed lock pinger :: caused by :: FailedToSatisfyReadPreference: Could not find host matching read preference { mode: "primary" } for set mongors1conf
2020-04-17T13:33:31.579+0000 W  SHARDING [mongosMain] Error initializing sharding state, sleeping for 2 seconds and trying again :: caused by :: FailedToSatisfyReadPreference: Error loading clusterID :: caused by :: Could not find host matching read preference { mode: "nearest" } for set mongors1conf
2020-04-17T13:33:31.579+0000 I  SHARDING [shard-registry-reload] Periodic reload of shard registry failed  :: caused by :: FailedToSatisfyReadPreference: could not get updated shard list from config server :: caused by :: Could not find host matching read preference { mode: "nearest" } for set mongors1conf; will retry after 30s

以下是配置服务器上的日志

2020-04-17T13:33:11.578+0000 I  NETWORK  [listener] connection accepted from 10.244.0.6:34400 #5 (1 connection now open)
2020-04-17T13:33:11.578+0000 I  NETWORK  [conn5] received client metadata from 10.244.0.6:34400 conn5: { driver: { name: "NetworkInterfaceTL", version: "4.2.5" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "18.04" } }
2020-04-17T13:33:11.589+0000 I  ACCESS   [conn5] Successfully authenticated as principal __system on local from client 10.244.0.6:34400
2020-04-17T13:33:38.197+0000 I  SHARDING [replSetDistLockPinger] Marking collection config.lockpings as collection version: <unsharded>
2020-04-17T13:33:38.202+0000 W  SHARDING [replSetDistLockPinger] pinging failed for distributed lock pinger :: caused by :: LockStateChangeFailed: findAndModify query predicate didn't match any lock document
2020-04-17T13:44:39.743+0000 I  CONTROL  [LogicalSessionCacheRefresh] Failed to create config.system.sessions: Cannot create config.system.sessions until there are shards, will try again at the next refresh interval
2020-04-17T13:44:39.743+0000 I  CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Cannot create config.system.sessions until there are shards
2020-04-17T13:44:39.743+0000 I  SH_REFR  [ConfigServerCatalogCacheLoader-1] Refresh for collection config.system.sessions took 0 ms and found the collection is not sharded
2020-04-17T13:44:39.743+0000 I  CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: Collection config.system.sessions is not sharded.
2020-04-17T13:44:42.570+0000 I  NETWORK  [conn5] end connection 10.244.0.10:37922 (0 connections now open)

我是mongodb的新手。花费大量时间将这张图表放在一起。我也检查了其他类似的问题。 could not find host matching read preferences in mongodb

我无法进一步调试。

mongodb kubernetes-helm
1个回答
0
投票

未运行(并非所有节点都在运行)

    不是副本集(未执行replSetInitiate或失败)
  • 从分片节点引用不正确(主机,IP或副本集名称错误)
  • 已启动并正在运行,但是由于防火墙规则,您的碎片无法访问它
  • 确保您可以在运行分片mongo的计算机上从mongod shell访问副本集节点。
  • © www.soinside.com 2019 - 2024. All rights reserved.