mongodb runtime_error ai_generated true

MongoServerError:均衡器失败:块移动失败,错误为 'ShardNotFound:分片没有可用的配置服务器主节点'

MongoServerError: Balancer failed: chunk move failed with error 'ShardNotFound: no config server primary available for shard'

ID: mongodb/sharded-cluster-balancer-stuck

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2024-03-20首次发现

版本兼容性

版本状态引入弃用备注
mongodb-4.2 active
mongodb-4.4 active
mongodb-5.0 active
mongodb-6.0 active
mongodb-7.0 active

根因分析

配置服务器副本集因网络问题或选举失败没有主节点,阻止了均衡器移动块。

English

The config server replica set has no primary due to network issues or election failure, preventing the balancer from moving chunks.

generic

官方文档

https://www.mongodb.com/docs/manual/reference/command/balancerStart/

解决方案

  1. Check config server replica set status: rs.status(). If no primary, force an election: rs.stepDown() on the current secondary that should be primary. Or restart the config server nodes one by one.
  2. Temporarily disable the balancer to reduce load: sh.stopBalancer(). Then fix the config server issue, then re-enable: sh.startBalancer().
  3. Ensure config server nodes have sufficient resources and network connectivity. Check logs for election issues. Example: grep 'election' /var/log/mongodb/mongod.log

无效尝试

常见但无效的做法:

  1. 90% 失败

    The error indicates no config server primary; manual moves also require a healthy config server.

  2. 80% 失败

    The balancer cannot start if the config server has no primary; this only re-enables the scheduler.

  3. 100% 失败

    This causes data loss and does not fix the underlying config server issue.