Search code examples
mongodbubuntupermissionsfile-permissions

Ubuntu changing location of mongoDB results in failed connection (Operation not permitted)


So I have installed MongoDB Community Edition on Ubuntu following the instructions provided here.

I successfully tested my connection by first starting the service and then use any client to connect. (robomongo and umongo).

Now because of the type of my work I will be storing GBs of files to my machine. Thus I needed to change the location of mongoDB. So I followed the steps below (mentioned here as well):

Step 1 : Open mongod.conf at \etc

Step 2:

Edit path to the deired one. My new path is as below

dbPath: /home/shouman/mongodb

Step 3: Copy data from the old path to the new path

Step 4: Update the new directory permission recursively to 777

Now I can't seem to start mongoDB after that. I checked the log file at /var/log/mongodb/mongod.lod and there seems to be a permission issue as mentioned below

/home/shouman/mongodb/WiredTiger.wt

Now you can notice few notes from that

  1. mongoDB now sees the new location. (it also created two lock files)
  2. I checked the permission for this specific file and it seems ok (check the picture at the end)
  3. I tried restarting mongoDB but still same issue

Here is the full log output

2017-04-17T18:19:59.466+0300 I CONTROL  [main] ***** SERVER RESTARTED *****
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] MongoDB starting : pid=3374 port=27017 dbpath=/home/shouman/mongodb 64-bit host=shouman-Lenovo-IdeaPad-Y500
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] db version v3.4.3
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] git version: f07437fb5a6cca07c10bafa78365456eb1d6d5e1
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] allocator: tcmalloc
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] modules: none
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] build environment:
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten]     distarch: x86_64
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten]     target_arch: x86_64
2017-04-17T18:19:59.471+0300 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/home/shouman/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-04-17T18:19:59.503+0300 I -        [initandlisten] Detected data files in /home/shouman/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-04-17T18:19:59.503+0300 I STORAGE  [initandlisten] 
2017-04-17T18:19:59.503+0300 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-17T18:19:59.503+0300 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-04-17T18:19:59.503+0300 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3454M,session_max=20000,eviction=(threads_min=4,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),
2017-04-17T18:19:59.507+0300 E STORAGE  [initandlisten] WiredTiger error (1) [1492442399:507878][3374:0x7f5379b49cc0], file:WiredTiger.wt, connection: /home/shouman/mongodb/WiredTiger.wt: handle-open: open: Operation not permitted
2017-04-17T18:19:59.508+0300 I -        [initandlisten] Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2017-04-17T18:19:59.508+0300 I STORAGE  [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating
2017-04-17T18:19:59.508+0300 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-04-17T18:19:59.508+0300 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2017-04-17T18:19:59.508+0300 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-04-17T18:19:59.508+0300 I CONTROL  [initandlisten] now exiting
2017-04-17T18:19:59.508+0300 I CONTROL  [initandlisten] shutting down with code:100

WireTiger.wt Permissions


Solution

  • OK. So it seems that I also needed to make mongod user the owner of the new mongoDB driectoty

    I found the answer in this questions

    MongoDB service doesn't start. errno:13 Permission denied