0
votes

I am using MongoDB 3.4 . Database is sharded in 2 shards and everything looks ok.
If one of the shards is down. How can I query data on the second shard from the mongos shell ??

1

1 Answers

0
votes

In practice, with a properly designed system, this is a situation that should never occur because every shard should consist of a replica set. When each shard is a replica set, you would have to have multiple failures for the shard to be down/unavailable.

If for some reason you do have a shard that is down some queries can still be performed. If the queries are targeted to only shards that are available, they will still work. But if your queries are broadcast queries, the query will fail.

If your shards are properly deployed as replica sets and you happen to have one or more shards that have no primary, your queries may still succeed if you specify a read preference that allows queries to secondaries. Or if running from the mongo shell, running rs.slaveOk() will do the same.