AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 770227
Accepted
Xudonax
Xudonax
Asked: 2016-04-14 23:07:46 +0800 CST2016-04-14 23:07:46 +0800 CST 2016-04-14 23:07:46 +0800 CST

MongoDB 的 SELinux 设置

  • 772

我正在尝试从 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.
centos7 selinux mongodb
  • 3 3 个回答
  • 8055 Views

3 个回答

  • Voted
  1. Best Answer
    Anton Makovetsky
    2016-04-15T00:03:37+08:002016-04-15T00:03:37+08:00

    如果您想以简单的方式为 Mongo 配置 SELINUX - 在您的 /var/log/audit/audit.log 上尝试audit2why以查看哪些违规行为会被拒绝,并使用audit2allow构建自定义策略。它适用于 80% 的事件。

    如果您仍然有问题 - 运行 audit2why 并手动修复其他问题。也许我们可以帮助您完成这一步。

    • 3
  2. Nic Cottrell
    2017-12-01T01:24:38+08:002017-12-01T01:24:38+08:00

    Runningsudo sealert -a /var/log/audit/audit.log在这里提供了一些有用的见解和对 SELinux 配置更改的建议。(我们也更改了 dbPath 值mongod.conf。)

    • 1
  3. Isaiah
    2021-04-03T03:42:09+08:002021-04-03T03:42:09+08:00
    chcon system_u:object_r:mongod_var_lib_t:s0 mongodb
    

    是什么为我解决了它。journalctl -xe即使根据输出,2auditallow 和所有爵士乐都不起作用

    • 0

相关问题

  • 如何在 Centos 上保持 openvpn 连接打开

  • LIST 上的 ProFTPd 超时

  • 与 AWS 中的其他系统相比,CentOS 报告的总内存较低

  • SELinux 阻止 Apache 写入文件

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve