我正在尝试从 mongodb.org 存储库在 CentOS 7.2 上安装 MongoDB。到目前为止一切都很好,但是主机已经为所有 MongoDB 数据文件创建了一个辅助磁盘 (/mongo)。这与 SELinux 权限冲突,导致 MongoDB 无法启动。我已经开始运行了setenforce 0
,但这并不是我真正想要运行生产服务器的方式。
我有相当多的 Linux 经验,但我所有的 SELinux 经验只是将其关闭。我找到了这个 CentOS SELinux 教程,它让我想到了运行
[user@machine lib]$ sudo chcon -Rv --type mongod_var_lib_t /mongo
changing security context of ‘/mongo/mongod.lock’
changing security context of ‘/mongo/journal/WiredTigerLog.0000000001’
changing security context of ‘/mongo/journal/WiredTigerPreplog.0000000001’
changing security context of ‘/mongo/journal/WiredTigerPreplog.0000000002’
changing security context of ‘/mongo/journal’
changing security context of ‘/mongo/WiredTiger.lock’
changing security context of ‘/mongo/WiredTiger’
changing security context of ‘/mongo/WiredTiger.wt’
changing security context of ‘/mongo/WiredTiger.turtle’
changing security context of ‘/mongo/WiredTigerLAS.wt’
changing security context of ‘/mongo/sizeStorer.wt’
changing security context of ‘/mongo/_mdb_catalog.wt’
changing security context of ‘/mongo/storage.bson’
changing security context of ‘/mongo/collection-0-7567754672580995921.wt’
changing security context of ‘/mongo/index-1-7567754672580995921.wt’
changing security context of ‘/mongo/diagnostic.data/metrics.2016-04-14T06-51-54Z-00000’
changing security context of ‘/mongo/diagnostic.data/metrics.interim’
changing security context of ‘/mongo/diagnostic.data’
changing security context of ‘/mongo’
[user@machine lib]$ ls -Z /mongo
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 collection-0-7567754672580995921.wt
drwxr-xr-x. mongod mongod system_u:object_r:mongod_var_lib_t:s0 diagnostic.data
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 index-1-7567754672580995921.wt
drwxr-xr-x. mongod mongod system_u:object_r:mongod_var_lib_t:s0 journal
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 _mdb_catalog.wt
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 mongod.lock
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 sizeStorer.wt
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 storage.bson
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 WiredTiger
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 WiredTigerLAS.wt
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 WiredTiger.lock
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 WiredTiger.turtle
-rw-r--r--. mongod mongod system_u:object_r:mongod_var_lib_t:s0 WiredTiger.wt
会解决这个问题。之后,我做了一个touch /.autorelabel
并重新启动。不幸的是,这并没有解决手头的问题。我将如何解决这个问题?
当前错误是: [user@machine lib]$ systemctl status mongod ● mongod.service - SYSV:Mongo 是一个可扩展的、面向文档的数据库。已加载:已加载 (/etc/rc.d/init.d/mongod) 活动:自 2016 年 4 月 14 日星期四 09:02:54 CEST 以来失败(结果:退出代码);2s 前 文档:man:systemd-sysv-generator(8) 进程:2180 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld runuser[2187]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld runuser[2187]: pam_unix(runuser:session): session closed for user mongod
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld mongod[2180]: Starting mongod: [FAILED]
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld systemd[1]: mongod.service: control process exited, code=exited status=1
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld systemd[1]: Unit mongod.service entered failed state.
Apr 14 09:02:54 LMG-TA-MONGO01.boolhosting.tld systemd[1]: mongod.service failed.