简体   繁体   English

Mongodb平衡很慢

[英]Mongodb balancing very slow

We are experiencing very slow balancing in our cluster. 我们的集群正在经历非常缓慢的平衡。 On our log, it seems that migration progress barely makes progress: 在我们的日志中,似乎迁移进度几乎没有取得进展:

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

Also, when we shard a new collection. 此外,当我们对新集合进行分片时。 It initially only starts with 8 chunks in the same primary replica set. 它最初只在相同的主副本集中以8个块开始。 It does not migrating chunks to other shards 它不会将块迁移到其他分片

Our configuration is 4 replica sets of (primary, secondary, arbiter) & 3 configs in a replica set. 我们的配置是副本集中的4个副本集(主要,辅助,仲裁)和3个配置。 Both sh.getBalancerState() & sh.isBalancerRunning() return true sh.getBalancerState()和sh.isBalancerRunning()都返回true

In MongoDB sharding performance depends upon the key chose for sharding the database. 在MongoDB中,分片性能取决于为分片数据库选择的密钥。 Since, your chunks are always stored on a single node it is highly probable that the shard key you have chosen is monotonically increasing . 因为,您的块总是存储在单个节点上,所以您选择的分片键极有可能单调递增 To avoid this issue, hash the key to allow proper balance of chunks across all the shards. 要避免此问题,请对密钥进行散列以允许在所有分片中正确平衡块。 Use the following command for hashed sharding. 使用以下命令进行散列分片。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM