Search code examples
mongodbsharding

MongoDB sh.status() and db.getShardDistribution() results not consistent about shards


When I run sh.status() on my MongoDB server, it shows that the collections are sharded, that there are 3 shards and identifies the primary shard in each database.

When I run db.getCollection('ReportRow').getShardDistribution(), it returns Collection reporting.ReportRow is not sharded, even though sh.status shows that it is.

Any ideas on why MongoDb would have this discrepancy?


Solution

  • The shard instances exist but the data is not being sharded.

    Check to insure the shard key exists on the collection as an index: - db.collection.getIndexes()