我设置了 3 个分片,但容量不足,所以我又添加了 3 个分片。(每个分片都是一个副本集)。但是数据并没有均匀地分布在集群中。我将 chunkSize 设置为标准的 64mb:
mongos> db.settings.find( { _id:"chunksize" } )
{ "_id" : "chunksize", "value" : 64 }
我认为这意味着当一个块达到 64mb 时,它会分成两个大小相同的块,大小均为 32mb。这就是这里演示的内容。这不正确吗?
这是我的分片分布:
mongos> db.accounts.getShardDistribution()
Shard rs_0 at rs_0/mongo_rs_0_member_1:27018,mongo_rs_0_member_2:27019,mongo_rs_0_member_3:27020
data : 137.62GiB docs : 41991598 chunks : 1882
estimated data per chunk : 74.88MiB
estimated docs per chunk : 22312
Shard rs_1 at rs_1/mongo_rs_1_member_1:27018,mongo_rs_1_member_2:27019,mongo_rs_1_member_3:27020
data : 135.2GiB docs : 41159069 chunks : 1882
estimated data per chunk : 73.56MiB
estimated docs per chunk : 21869
Shard rs_2 at rs_2/mongo_rs_2_member_1:27018,mongo_rs_2_member_2:27019,mongo_rs_2_member_3:27020
data : 219.92GiB docs : 69739096 chunks : 1882
estimated data per chunk : 119.66MiB
estimated docs per chunk : 37055
Shard rs_3 at rs_3/mongo_rs_3_member_1:27018,mongo_rs_3_member_2:27019,mongo_rs_3_member_3:27020
data : 101.52GiB docs : 30650628 chunks : 1882
estimated data per chunk : 55.23MiB
estimated docs per chunk : 16286
Shard rs_4 at rs_4/mongo_rs_4_member_1:27018,mongo_rs_4_member_2:27019,mongo_rs_4_member_3:27020
data : 103.38GiB docs : 31071379 chunks : 1883
estimated data per chunk : 56.22MiB
estimated docs per chunk : 16500
Shard rs_5 at rs_5/mongo_rs_5_member_1:27018,mongo_rs_5_member_2:27019,mongo_rs_5_member_3:27020
data : 101.1GiB docs : 30516395 chunks : 1881
estimated data per chunk : 55.04MiB
estimated docs per chunk : 16223
Totals
data : 798.77GiB docs : 245128165 chunks : 11292
Shard rs_0 contains 17.23% data, 17.13% docs in cluster, avg obj size on shard : 3KiB
Shard rs_1 contains 16.92% data, 16.79% docs in cluster, avg obj size on shard : 3KiB
Shard rs_2 contains 27.53% data, 28.45% docs in cluster, avg obj size on shard : 3KiB
Shard rs_3 contains 12.7% data, 12.5% docs in cluster, avg obj size on shard : 3KiB
Shard rs_4 contains 12.94% data, 12.67% docs in cluster, avg obj size on shard : 3KiB
Shard rs_5 contains 12.65% data, 12.44% docs in cluster, avg obj size on shard : 3KiB
这是怎么回事?当设置为 chunkSize 时,前 3 个分片/副本集的平均大小如何大于 64mb?Rs_2 是 119mb!Rs_2 有 27.53% 的数据,而它应该有 16.6%。
我的 shardkey 中的基数非常高,而且它不是单调递增的。
我应该在这里做什么?我可以手动找到大块并将它们拆分,但这很痛苦。我会降低我的 chunkSize 吗?我需要运行一些服务/呼叫来自动执行此操作吗?