[initandlisten] Detected unclean shutdown - /var/lib/mongo/mongod.lock is not empty

One problem description

mongo起不来,日志里有如下报错:
2020-12-29T09:31:29.933+0800 W -        [initandlisten] Detected unclean shutdown - /var/lib/mongo/mongod.lock is not empty.
2020-12-29T09:31:29.933+0800 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted
2020-12-29T09:31:29.933+0800 F -        [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 170

Two reasons for the error

Mongo is not shut down normally, the command to shut down mongo normally:

use admin

db.shutdownServer()

Three solutions

Delete the lock file, repair the database, and then start mongo.

mv mongod.lock mongod.lock_bak_20201229
mongod --repair --dbpath / var / lib / mongo

chown -R mongod:mongod /var/lib/mongo #mongod is the owner of /var/lib/mongo. Please modify the user name according to your actual situation. If the owner is root, you do not need to perform this operation.
/usr/bin/mongod -f /etc/mongod.conf

 

Guess you like

Origin blog.csdn.net/yabignshi/article/details/111880733