Reputation: 91
I recently installed mongoDB in Amazon Linux and I am able to start mongod using the service command.
sudo service mongod start
Above works as expected.
Today I installed mongoDB in Centos 7 following the instructions in the mongodb site.
Now when I start the service using the same command as mentioned above, the service is not able to start.
I have done the following checks they look correct, so not sure what is going on here.
Journal entry looks like this:
[centos@ip-172-31-16-240 init.d]$ sudo journalctl -xn -- Logs begin at Thu 2015-03-26 11:45:57 UTC, end at Thu 2015-03-26 12:33:34 UTC. -- Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal mongod[1645]: ******>>>> mongod user is mongod Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal runuser[1654]: pam_unix(runuser:session): session opened for user mongod by (uid=0) Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal runuser[1654]: pam_unix(runuser:session): session closed for user mongod Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal mongod[1645]: Starting mongod: [FAILED] Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=1 Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database.. -- Subject: Unit mongod.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mongod.service has failed. -- -- The result is failed. Mar 26 12:26:44 ip-172-31-16-240.ap-southeast-1.compute.internal systemd[1]: Unit mongod.service entered failed state. Mar 26 12:26:49 ip-172-31-16-240.ap-southeast-1.compute.internal sudo[1660]: centos : TTY=pts/0 ; PWD=/etc/rc.d/init.d ; USER=root ; COMMAND=/bin/journalctl -xn Mar 26 12:28:00 ip-172-31-16-240.ap-southeast-1.compute.internal sudo[1664]: centos : TTY=pts/1 ; PWD=/home/centos ; USER=root ; COMMAND=/bin/less /var/log/mongodb/mongod.log Mar 26 12:33:34 ip-172-31-16-240.ap-southeast-1.compute.internal sudo[1668]: centos : TTY=pts/0 ; PWD=/etc/rc.d/init.d ; USER=root ; COMMAND=/bin/journalctl -xn [centos@ip-172-31-16-240 init.d]$
However, if I start using sudo mongod, the mongod process starts up.
Any ideas why the service command is not working?
Upvotes: 3
Views: 9932
Reputation: 91
Just incase anyone encountered this problem, this is how I fixed. After all it was permission related and SELinux security context which is set to enforced by default.
so, after you attempt to start mongod service and it fails, run this command and this should show you the reason if anything permission related.
sudo ausearch -m avc -ts today | audit2allow
You would see somethign like below for mongod related audits allow mongod_t default_t:file getattr;
To fix the above error, you do the following:
967 30/03/15 07:06:52 sudo chcon -Rv --type=mongod_var_lib_t /data
Note /data/db is where my mongod data files are located.
Upvotes: 3