MongoDB Operation Not Permitted

11,149

Solution 1

Assuming permissions are correct. It could be an selinux issue, try:

setenforce 0

then try to start the server. If the server starts, you will have to use semanage to set the proper context to the mongo data folder

Solution 2

Did you try this?

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

Share:
11,149
Goodwin
Author by

Goodwin

Updated on June 26, 2022

Comments

  • Goodwin
    Goodwin almost 2 years

    MongoDB was working perfectly until one day it generated a lock file and stopped starting with the following error:

    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
    

    I have removed all packages and reinstalled all of the mongodb services with no luck.

  • Goodwin
    Goodwin over 7 years
    yes I have made mongod the owner of the folder and have even tried making all the files read write.
  • Shreya Batra
    Shreya Batra over 7 years
    Make sure you do not have a mongod instance running. See if there is an instance running in the background by running the this command : ps aux | grep mongo if there is like : 24337 bla bla mongod do: kill 24337 and then yo might be able to run it fine.
  • Dan Nissenbaum
    Dan Nissenbaum about 6 years
    @EricRich even if there is no other option because 3rd-party tools will not work otherwise?
  • Youn Elan
    Youn Elan about 6 years
    @DanNissenbaum my answer focused on diagnosing the issue. if your system works with selinux in non enforcing mode, you might have to change the context of the data folder and its contents with chcon to change context, semanage to make policy changes or use audit2allow on security logs to generate rules for you. The video goes into how to use some of those tools but there are plenty of how tos which will show you how to generate a policy or at least set your application (like mongo) in permisssive mode - where everything except that application is unbound