MongoDB service did not start successfully after running service mongod start
Problem Description
Check the log (/var/log/mongodb/mongodb.log) for the following information
Wiredtiger error(13).....file:WiredTiger.wt,connection:/var/lib/mongodb/WiredTiger.turtle:handle-open:open:Permission denied
the cause of the problem
1. Permission problem.
service mongod startThe default user used at startup is, you mongodbcan view system files ( /lib/systemd/system/mongod.service)
which contains
[Service]
User=mongodb
Group=mongodb
Then in view( /var/lib/mongodb/WiredTiger.turtle) file permissions, use the command
cd /var/libls -l /var/lib/mongodb
View permission discovery WiredTiger.turtleand the permissions of several other files are root
Therefore, because the permissions of the mogodb user cannot access files under root permissions, the service fails to start.
But why do the permissions of these files become root?
My reason is that I have used the root user to operate the database (using the mongod command under rootx, etc.), which caused the permissions of the file to change and can no longer be used (service mongod start).
solution
Option One:
# storage.dbPath
chown -R mongodb:mongodb /var/lib/mongodb
# systemLog.path
sudo chown -R mongodb:mongodb /var/log/mongodb
Change the data file permissions backmongodb
Then you can start service mongo startit again, but if you operate the database as the root user, the above problems will still occur. At the same time, it is highly recommended not to use the database under the root user.
Option 2 (not recommended for security reasons):
Revise
/lib/systemd/system/mongod.service
In useris root, Groupfor root.
then start again service mongod start
0 Comments