Command to know Shard distribution from mongos/router
mongos> sh.status()
— Sharding Status —
sharding version: {
“_id” : 1,
“minCompatibleVersion” : 5,
“currentVersion” : 6,
“clusterId” : ObjectId(“568d598d58c8ebe6f4ccaf19”)
}
shards:
{ “_id” : “rs1”, “host” : “rs1/dbversity.com:27010,dbversity.com:27011” }
{ “_id” : “rs2”, “host” : “rs2/dbversity.com:27020,dbversity.com:27021” }
{ “_id” : “rs3”, “host” : “rs3/dbversity.com:27030,dbversity.com:27031” }
active mongoses:
“3.2.0” : 1
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
2 : Success
1 : Failed with error ‘aborted’, from rs1 to rs2
databases:
{ “_id” : “dbversity”, “primary” : “rs1”, “partitioned” : true }
dbversity.dbfry
shard key: { “user_id” : 1 }
unique: false
balancing: true
chunks:
rs1 1
rs2 1
rs3 1
{ “user_id” : { “$minKey” : 1 } } –>> { “user_id” : 2 } on : rs2 Timestamp(2, 0)
{ “user_id” : 2 } –>> { “user_id” : 14 } on : rs3 Timestamp(3, 0)
{ “user_id” : 14 } –>> { “user_id” : { “$maxKey” : 1 } } on : rs1 Timestamp(3, 1)
mongos>
mongos>
mongos> db.dbfry.getShardDistribution()
Shard rs1 at rs1/dbversity.com:27010,dbversity.com:27011
data : 8MiB docs : 99987 chunks : 1
estimated data per chunk : 8MiB
estimated docs per chunk : 99987
Shard rs2 at rs2/dbversity.com:27020,dbversity.com:27021
data : 84B docs : 1 chunks : 1
estimated data per chunk : 84B
estimated docs per chunk : 1
Shard rs3 at rs3/dbversity.com:27030,dbversity.com:27031
data : 1008B docs : 12 chunks : 1
estimated data per chunk : 1008B
estimated docs per chunk : 12
Totals
data : 8.01MiB docs : 100000 chunks : 3
Shard rs1 contains 99.98% data, 99.98% docs in cluster, avg obj size on shard : 84B
Shard rs2 contains 0% data, 0% docs in cluster, avg obj size on shard : 84B
Shard rs3 contains 0.01% data, 0.01% docs in cluster, avg obj size on shard : 84B
mongos>
mongos>
mongos>