Debian上MongoDB故障排查方法
一 快速定位流程
二 连接问题排查
三 性能与查询问题排查
四 复制集与数据一致性排查
五 常见错误与处理清单
| 症状 | 快速检查 | 处理建议 |
|---|---|---|
| Connection refused | 服务是否运行、端口是否监听、防火墙是否放行 | 启动服务;确认 **netstat -anp |
| 服务无法启动 | 配置文件语法、路径权限、磁盘空间、mongod.lock | 修正 /etc/mongod.conf;确保 dbPath/logPath 权限;检查磁盘;必要时移除 mongod.lock 后启动 |
| Write concern failed | rs.status()、成员健康、网络 | 恢复多数派;调整 w/wtimeout;修复滞后或异常成员 |
| Query performance issue | explain、索引、慢查询日志 | 增加/调整索引;优化查询;启用并分析慢查询 |
| No Server Chosen by ReadPreference | ReadPreference 与拓扑 | 调整读偏好或恢复目标成员健康 |
| 端口被占用 | **netstat -anp | grep 27017** |