MongoDB: Can not connect databases after adding shard to cluster

586 Views Asked by At

We have installed the following components: 1. config replica set (3 nodes) 2. shard replica set (3 nodes) 3. mongos on 7 ubuntu servers After connecting to the primary shard, we added a new database and checked that it appears on the other 2 secondaries. After that, we connected to the mongos with an admin user and added the shard replica to the cluster using:.

sh.addShard()

Now, when running the command:

sh.status()

under "shardings", we can see the database we've created before but when typing

show db

we don't see any database other than the admin and the config databases. We don't understand why we can't see and query the database we've created. Any ideas?

In addition, if, in that stage, we create another database (on the primary) and we run (on mongos)

sh.status()

we don't see the new database we have just created (meaning that shard cluster can not recognize any database that was created after adding the shard). Is there any way to re-map the shared cluster (without deleting the shard replica set and re-add it)? Thanks

1

There are 1 best solutions below

0
On

you need to initialize your mongos at your query router. https://docs.mongodb.com/manual/reference/method/rs.initiate/

rs.initiate( { _id: "configReplSet", configsvr: true, members: [ { _id: 0, host: "mongo-config-1:27017" }] } )