# MongoServerError：ShardNotFound：分片没有可用的配置服务器主节点

- **ID:** `mongodb/sharded-cluster-no-config-primary`
- **领域:** mongodb
- **类别:** network_error
- **错误码:** `70`
- **验证级别:** ai_generated
- **修复率:** 70%

## 根因

配置服务器副本集由于网络分区、选举失败或节点崩溃而没有主节点。

## 版本兼容性

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

## 解决方案

1. ```
   检查配置服务器副本集状态：在配置服务器上运行rs.status()，必要时强制重新选举：在当前主节点上运行rs.stepDown()或使用rs.reconfig()添加新成员。
   ```
2. ```
   如果写操作不关键，临时将读操作路由到从节点：db.getMongo().setReadPref('secondaryPreferred')
   ```

## 无效尝试

- **** — The mongos is not the issue; the config server replica set needs repair. (90% 失败率)
- **** — Connection pool size does not affect config server primary availability. (95% 失败率)
