现在列出来 mongodb异常关闭打不开的几种解决方法。
我的原因是磁盘满了,让后mongodb就挂了,清理了磁盘也打不开,后来使用网上各种方法也打不开。
最后还是用下面的第一种方法打开的,虽然也不知道diagnostic.data是干啥的, 貌似记录分析用的
报错1:
rm -f /var/lib/mongo/diagnostic.data/*
sudo ./mongod
报错2:
sudo rm /data/db/mongod.lock
报错3:
sudo netstat -anp|more激活Internet连接 (服务器和已建立连接的)Proto Recv-Q Send-Q Local Address Foreign Address StatePID/Program nametcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN2515/./mongodsudo kill 2515
正确的关闭方法:停止Mongodb
/usr/local/mongodb/bin:$ ./mongod> use admin;switched to db admin> db.shutdownServer();server should be down...
2018-07-20T23:06:30.230+0800 I NETWORK [initandlisten] waiting for connections on port 270172018-07-20T23:13:37.028+0800 I NETWORK [listener] connection accepted from 127.0.0.1:56738 #1 (1 connection now open)2018-07-20T23:13:37.029+0800 I NETWORK [conn1] received client metadata from 127.0.0.1:56738 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.0" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "18.04" } }2018-07-20T23:13:59.951+0800 I COMMAND [conn1] terminating, shutdown command received { shutdown: 1.0, $db: "admin" }2018-07-20T23:13:59.951+0800 I NETWORK [conn1] shutdown: going to close listening sockets...2018-07-20T23:13:59.951+0800 I NETWORK [conn1] removing socket file: /tmp/mongodb-27017.sock2018-07-20T23:13:59.952+0800 I FTDC [conn1] Shutting down full-time diagnostic data capture2018-07-20T23:13:59.956+0800 I STORAGE [conn1] WiredTigerKVEngine shutting down2018-07-20T23:14:00.049+0800 I STORAGE [conn1] shutdown: removing fs lock...2018-07-20T23:14:00.049+0800 I CONTROL [conn1] now exiting2018-07-20T23:14:00.049+0800 I CONTROL [conn1] shutting down with code:0