Mongodb平衡非常缓慢



我们在集群中遇到了非常缓慢的平衡。在我们的日志中,迁移进度似乎几乎没有进展:

2016-01-25T22:21:15.907-0600 I SHARDING [conn142] moveChunk data transfer progress: { active: true, ns: "music.fav_artist_score", from: "rs1/MONGODB01-SRV:27017,MONGODB05-SRV:27017", min: { _id.u: -9159729253516193447 }, max: { _id.u: -9157438072680830290 }, shardKeyPattern: { _id.u: "hashed" }, state: "clone", counts: { cloned: 128, clonedBytes: 12419, catchup: 0, steady: 0 }, ok: 1.0 } my mem used: 0
2016-01-25T22:21:16.932-0600 I SHARDING [conn142] moveChunk data transfer progress: { active: true, ns: "music.fav_artist_score", from: "rs1/MONGODB01-SRV:27017,MONGODB05-SRV:27017", min: { _id.u: -9159729253516193447 }, max: { _id.u: -9157438072680830290 }, shardKeyPattern: { _id.u: "hashed" }, state: "clone", counts: { cloned: 128, clonedBytes: 12419, catchup: 0, steady: 0 }, ok: 1.0 } my mem used: 0
2016-01-25T22:21:17.957-0600 I SHARDING [conn142] moveChunk data transfer progress: { active: true, ns: "music.fav_artist_score", from: "rs1/MONGODB01-SRV:27017,MONGODB05-SRV:27017", min: { _id.u: -9159729253516193447 }, max: { _id.u: -9157438072680830290 }, shardKeyPattern: { _id.u: "hashed" }, state: "clone", counts: { cloned: 128, clonedBytes: 12419, catchup: 0, steady: 0 }, ok: 1.0 } my mem used: 0

此外,当我们对新集合进行分片时。它最初仅从同一主副本集中的 8 个区块开始。它不会将块迁移到其他分片

我们的配置是 4 个副本集(主副本、辅助副本、仲裁器)和一个副本集中的 3 个配置。sh.getBalancerState() 和 sh.isBalancerRunning() 都返回 true

在MongoDB中,分片性能取决于为分片数据库选择的键。由于您的块始终存储在单个节点上,因此您选择的分片键很可能是单调增加的。为避免此问题,请对密钥进行哈希处理,以允许在所有分片之间适当平衡块。使用以下命令进行哈希分片。

sh.shardCollection( "<your-db>", { <shard-key>: "hashed" } )

最新更新