Estou tentando instalar o MongoDB no CentOS 7.2 do repositório mongodb.org. Até aí tudo bem, mas o hoster criou um disco secundário (/mongo) para todos os arquivos de dados do MongoDB. Isso entra em conflito com as permissões do SELinux, tornando o MongoDB incapaz de iniciar. Eu comecei executando setenforce 0
, mas não é assim que eu gostaria de executar um servidor de produção.
Eu tenho bastante experiência em Linux, mas toda a minha experiência no SELinux é apenas desligá-lo. Encontrei este tutorial do CentOS SELinux , que me fez pensar em executar
[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
resolveria o problema. Depois, fiz um touch /.autorelabel
e reiniciei. Isso, infelizmente, não resolveu o problema em questão. Como eu iria consertar isso?
O erro atual é: [user@machine lib]$ systemctl status mongod ● mongod.service - SYSV: Mongo é um banco de dados escalável orientado a documentos. Carregado: carregado (/etc/rc.d/init.d/mongod) Ativo: falhou (Resultado: código de saída) desde qui 2016-04-14 09:02:54 CEST; 2s ago Docs: man:systemd-sysv-generator(8) Processo: 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.