Issue
I followed this doc to install MongoDB 3.2.1 on CentOS 7. After installing, I change the owner and group of var/lib/mongo
and var/log/mongodb/mongod.log
to root:root
.
When I start the mongodb with service mongod start
, it just shows
Starting mongod (via systemctl): Job for mongod.service failed. See 'systemctl status mongod.service' and 'journalctl -xn' for details.[FAILED]
I have run the two commands to show details.
systemctl status mongod.service
shows
mongod.service - SYSV: Mongo is a scalable, document-oriented database.
Loaded: loaded (/etc/rc.d/init.d/mongod)
Active: failed (Result: exit-code) since Wen 2016-01-27 18:32:46 CST; 14s ago
Process: 24913 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
Main PID: 23711 (code=exited, status=0/SUCCESS)
1月 27 18:32:45 server1 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
1月 27 18:32:45 server1 runuser[24920]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
1月 27 18:32:46 server1 mongod[24913]: Starting mongod: [FAILED]
1月 27 18:32:46 server1 systemd[1]: mongod.service: control process exited, code=exited status=1
1月 27 18:32:46 server1 systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
1月 27 18:32:46 server1 systemd[1]: Unit mongod.service entered failed state.
journalctl -xn
shows
-- Logs begin at 日 2016-01-24 16:33:05 CST, end at Wen 2016-01-27 18:32:46 CST. --
1月 27 18:32:15 server1 sshd[24879]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
1月 27 18:32:17 server1 sshd[24879]: Failed password for root from 182.100.67.59 port 10013 ssh2
1月 27 18:32:45 server1 sudo[24896]: root : TTY=pts/0 ; PWD=/var/log/mongodb ; USER=root ; COMMAND=/sbin/service mongod start
1月 27 18:32:45 server1 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
-- Subject: Unit mongod.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongod.service has begun starting up.
1月 27 18:32:45 server1 runuser[24920]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
1月 27 18:32:46 server1 runuser[24920]: pam_unix(runuser:session): session closed for user mongod
1月 27 18:32:46 server1 mongod[24913]: Starting mongod: [FAILED]
1月 27 18:32:46 server1 systemd[1]: mongod.service: control process exited, code=exited status=1
1月 27 18:32:46 server1 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.
1月 27 18:32:46 server1 systemd[1]: Unit mongod.service entered failed state.
I accessed the server with ssh key, no password.
Solution
Is the any reason to change ownership to root?
Both /var/lib/mongo
and /var/log/mongodb
should be writable by mongodb user.
By default it is mongodb:mongodb
. Check which user runs mongodb service in /etc/init.d/mongodb
. If it is something like DAEMONUSER=${DAEMONUSER:-mongodb}
then chown your directories back to this user.
Answered By - Alex Blex Answer Checked By - Pedro (WPSolving Volunteer)