70
mongodb
network_error
ai_generated
partial
MongoServerError:ShardNotFound:分片没有可用的配置服务器主节点
MongoServerError: ShardNotFound: no config server primary available for shard
ID: mongodb/sharded-cluster-no-config-primary
70%修复率
88%置信度
1证据数
2024-01-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| mongodb 7.0 | active | — | — | — |
| mongodb 6.0 | active | — | — | — |
| mongodb 5.0 | active | — | — | — |
| mongodb 4.4 | active | — | — | — |
根因分析
配置服务器副本集由于网络分区、选举失败或节点崩溃而没有主节点。
English
The config server replica set has no primary node due to network partition, election failure, or node crash.
官方文档
https://www.mongodb.com/docs/manual/reference/error-codes/#mongodb-error-70解决方案
-
检查配置服务器副本集状态:在配置服务器上运行rs.status(),必要时强制重新选举:在当前主节点上运行rs.stepDown()或使用rs.reconfig()添加新成员。
-
如果写操作不关键,临时将读操作路由到从节点:db.getMongo().setReadPref('secondaryPreferred')
无效尝试
常见但无效的做法:
-
90% 失败
The mongos is not the issue; the config server replica set needs repair.
-
95% 失败
Connection pool size does not affect config server primary availability.