MongoDB服务启动异常 status=14
MongoDB进程 kill -9之后导致服务起不来了
[root@yaong etc]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
......
Process: 9526 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
......
Aug 19 10:26:12 yaong systemd[1]: mongod.service: control process exited, code=exited status=14
......
从网上找了找相关资料,大致说法是:mongo内存管理很特殊,kill -9 很可能影响存库操作 如果不是在写磁盘的时候宕掉,可以通过repair命令进行修复,会丢失最后一次写磁盘的时刻到宕掉时刻期间的数据 如果赶上写磁盘的时候进程宕掉,repair也不能恢复数据,很可能会丢失掉全部数据 尝试进行修复
[root@yaong etc]# /usr/bin/mongod -f /etc/mongod.conf --repair
about to fork child process, waiting until server is ready for connections.
forked process: 9575
child process started successfully, parent exiting
再次查看服务状态
[root@yaong etc]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
Active: failed (Result: exit-code) since Thu 2021-08-19 10:27:05 CST;
6s ago
Process: 9618 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=1/FAILURE)
......
Aug 19 10:27:05 yaong systemd[1]: mongod.service: control process exited, code=exited status=1
......
燃鹅还是存在其他问题,鉴于库里没有存啥数据,统统干掉,重头再来
rm -rf /var/lib/mongo/*
rm -rf /var/log/mongodb/*
cat /var/run/mongodb/mongod.pid
rm -rf /data/db/mongod.lock
rm -rf /var/lib/mongo/mongod.lock
再次启动服务,服务就起来了
[root@yaong mongodb]# systemctl restart mongod
[root@yaong mongodb]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
Active: active (running) since Thu 2021-08-19 10:47:14 CST;
3s ago
Docs: https://docs.mongodb.org/manual
Process: 10836 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
......
Main PID: 10839 (mongod)
CGroup: /system.slice/mongod.service
└─10839 /usr/bin/mongod -f /etc/mongod.conf[root@yaong etc]# ps -ef | grep mongo
mongod1083910 10:47 ?00:00:22 /usr/bin/mongod -f /etc/mongod.conf
root1594916270 12:25 pts/000:00:00 grep --color=auto mongo
至此,提醒大家停止mongo进程一定要谨慎,推荐三种较稳妥的方式:
交互模式下:除了服务启动模式,还可以命令行后台启动
use adminmongo命令:
db.shutdownServer()
mongod --shutdown系统命令
kill
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork
[root@yaong etc]# ps -ef | grep mongo
root1022215 10:37 ?00:00:01 mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork
root1028116270 10:38 pts/000:00:00 grep --color=auto mongo
【MongoDB服务启动异常 status=14】与之对应的是停止进程的命令
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --shutdown
produced by yaong !
推荐阅读
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- 社保代缴公司服务费包含哪些
- Hive常见问题汇总
- 私有化轻量级持续集成部署方案--03-部署web服务(下)
- 注册分销商的骄傲
- 探索免费开源服务器tomcat的魅力
- [源码解析]|[源码解析] NVIDIA HugeCTR,GPU版本参数服务器---(3)
- 如何启动改变
- spring|spring boot项目启动websocket
- Android系统启动之init.rc文件解析过程