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

- **ID:** `mongodb/sharded-cluster-balancer-stuck`
- **领域:** mongodb
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

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

## 版本兼容性

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

## 解决方案

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
   ```

## 无效尝试

- **** — The error indicates no config server primary; manual moves also require a healthy config server. (90% 失败率)
- **** — The balancer cannot start if the config server has no primary; this only re-enables the scheduler. (80% 失败率)
- **** — This causes data loss and does not fix the underlying config server issue. (100% 失败率)
