我在 MongoDB Sharding 部署中遇到了一个问题。我有 4 个副本集,它们都有非常相似的块。但是它们每个块的估计数据都非常不同。
mongos> db.hadCompressed.getShardDistribution()
Shard rsmmhad01 at rsmmhad01/mmhad01a:27017,mmhad01b:27017
data : 578.74GiB docs : 933429549 chunks : 23812
estimated data per chunk : 24.88MiB
estimated docs per chunk : 39199
Shard rsmmhad02 at rsmmhad02/mmhad02a:27017,mmhad02b:27017
data : 55.18GiB docs : 91659330 chunks : 23812
estimated data per chunk : 2.37MiB
estimated docs per chunk : 3849
Shard rsmmhad03 at rsmmhad03/mmhad03a:27017,mmhad03b:27017
data : 218.62GiB docs : 368024030 chunks : 23814
estimated data per chunk : 9.4MiB
estimated docs per chunk : 15454
Shard rsmmhad04 at rsmmhad04/mmhad04a:27017,mmhad04b:27017
data : 406.31GiB docs : 640265568 chunks : 23814
estimated data per chunk : 17.47MiB
estimated docs per chunk : 26886
Totals
data : 1258.88GiB docs : 2033378477 chunks : 95252
Shard rsmmhad01 contains 45.97% data, 45.9% docs in cluster, avg obj size on shard : 665B
Shard rsmmhad02 contains 4.38% data, 4.5% docs in cluster, avg obj size on shard : 646B
Shard rsmmhad03 contains 17.36% data, 18.09% docs in cluster, avg obj size on shard : 637B
Shard rsmmhad04 contains 32.27% data, 31.48% docs in cluster, avg obj size on shard : 681B
集群中的块大小定义为 64Mb。密钥分布如下:
db.had
shard key: {
"chkin" : 1,
"n" : 1,
"occ" : 1,
"nid" : 1,
"rtype" : 1,
"gid" : 1,
"hid" : 1
}
unique: false
balancing: true
chunks:
rsmmhad01 23812
rsmmhad02 23812
rsmmhad03 23814
rsmmhad04 23814
我的数据库中没有太多巨型对象(不超过 10 或 12)。
例如,将块大小从 64Mb 减小到 16Mb 是否有用?或者也许更改分片键会有帮助?
提前致谢。