I want to use mongodb-shard for my project. I created a helm chart https://github.com/b-rohit/mongodb-shard-chart to deploy to kubernetes cluster.
I use kind
cluster running locally to test it. The config and shard servers are running properly. I am able to execute commands in their mongo shells. The mongos server is not able to connect to the replica set in config server. I get following error message in 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
On config server logs are following
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)
I am new to mongodb. It took lot of time to put this chart together. I checked other similar questions also. could not find host matching read preferences in mongodb
I am not able to debug it further.
Your config server replica set is either:
Ensure you can access the replica set nodes from mongo
shell from the machines on which the shard mongod
s are running.