【问题标题】:MongoDB Operation Not Permitted不允许 MongoDB 操作
【发布时间】:2016-12-28 16:52:58
【问题描述】:

MongoDB 一直运行良好,直到有一天它生成了一个锁定文件并停止启动并出现以下错误:

16-12-28T17:50:14.559+0100 I CONTROL  [initandlisten] build environment:
2016-12-28T17:50:14.559+0100 I CONTROL  [initandlisten]     distmod: debian71
2016-12-28T17:50:14.559+0100 I CONTROL  [initandlisten]     distarch: x86_64
2016-12-28T17:50:14.559+0100 I CONTROL  [initandlisten]     target_arch: x86_64
2016-12-28T17:50:14.559+0100 I CONTROL  [initandlisten] options: {}
2016-12-28T17:50:14.577+0100 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-12-28T17:50:14.577+0100 I STORAGE  [initandlisten]
2016-12-28T17:50:14.577+0100 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2016-12-28T17:50:14.577+0100 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2016-12-28T17:50:14.577+0100 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1024M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-12-28T17:50:14.590+0100 E STORAGE  [initandlisten] WiredTiger error (1) [1482943814:590694][32048:0x7f27c7cdcc80], file:WiredTiger.wt, connection: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2016-12-28T17:50:14.591+0100 I -        [initandlisten] Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2016-12-28T17:50:14.591+0100 I STORAGE  [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating
2016-12-28T17:50:14.591+0100 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2016-12-28T17:50:14.591+0100 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2016-12-28T17:50:14.591+0100 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2016-12-28T17:50:14.591+0100 I CONTROL  [initandlisten] now exiting
2016-12-28T17:50:14.591+0100 I CONTROL  [initandlisten] shutting down with code:100

我已经删除了所有包并重新安装了所有 mongodb 服务,但没有成功。

【问题讨论】:

    标签: mongodb server vps


    【解决方案1】:

    你试过了吗?

    sudo chown -R ⁠⁠⁠⁠id -u⁠⁠⁠⁠⁠/data/db

    【讨论】:

    • 是的,我已将 mongod 设为文件夹的所有者,甚至尝试将所有文​​件设为读写。
    • 确保您没有运行 mongod 实例。通过运行以下命令查看是否有实例在后台运行:ps aux | grep mongo 如果有这样的:24337 bla bla mongod do: kill 24337 然后你就可以运行它了。
    【解决方案2】:

    假设权限是正确的。可能是selinux的问题,试试:

    setenforce 0
    

    然后尝试启动服务器。如果服务器启动,您将不得不使用 semanage 为 mongo 数据文件夹设置正确的上下文

    【讨论】:

    • @EricRich 即使没有其他选择,因为 3rd-party 工具将无法正常工作?
    • @DanNissenbaum 我的回答集中在诊断问题上。如果您的系统在非强制模式下使用 selinux,您可能必须使用 chcon 更改数据文件夹的上下文及其内容以更改上下文,使用 semanage 进行策略更改或在安全日志上使用 audit2allow 为您生成规则。该视频介绍了如何使用其中一些工具,但有很多方法将向您展示如何生成策略或至少将您的应用程序(如 mongo)设置为许可模式 - 除了该应用程序之外的所有内容都是未绑定的跨度>
    猜你喜欢
    • 1970-01-01
    • 2012-01-03
    • 2021-02-10
    • 2021-01-01
    • 2014-11-01
    • 2014-06-30
    • 2012-03-19
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多