我最近在Amazon Linux中安装了mongoDB,我可以使用service命令启动mongod。
sudo service mongod start
以上按预期工作。
今天我按照mongodb网站上的说明在Centos 7中安装了mongoDB。
现在,当我使用与上述相同的命令启动服务时,服务无法启动。
我做了以下检查他们看起来是正确的,所以不知道这里发生了什么。
日记条目如下:
[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]$
但是,如果我开始使用 sudo mongod ,mongod进程就会启动。
为什么服务命令不起作用的任何想法?
答案 0 :(得分:3)
因此,在您尝试启动mongod服务并且它失败后,运行此命令,这应该显示相关权限的原因。
sudo ausearch -m avc -ts today | audit2allow
You would see somethign like below for mongod related audits allow mongod_t default_t:file getattr;
要解决上述错误,请执行以下操作:
967 30/03/15 07:06:52 sudo chcon -Rv --type=mongod_var_lib_t /data
注意/ data / db是我的mongod数据文件所在的位置。