Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied

前端 未结 28 1447
执念已碎
执念已碎 2020-11-29 14:39

How to I get mongo to use a mounted drive on ec2? I really do not understand. I attached a volume on ec2 formatted the drive as root and start as root and yet as root I ca

相关标签:
28条回答
  • 2020-11-29 15:04

    I had similar issue, the actual reason was that there was mongod session running already from my previous attempt.

    I ran

    killall mongod
    

    and everything else ran just as expected.

    killall command would send a TERM signal to all processes with a real UID. So this kills all the running instances of mongod so that you could start your own.

    0 讨论(0)
  • 2020-11-29 15:06

    Removing the mongodb.lock file was not the issue in my case. I did so and got an error about the port being in use: [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017. I found another solution here: unable to start mongodb local server with instructions to kill the process:

    1. Find out from netstat which process is running mongodb port (27017)

      sudo netstat -tulpn | grep :27017

      Output will be: tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 1412/mongod

    2. Kill the appropriate process.

      sudo kill 1412 (replace 1412 with your process ID found in step 1)

    And I was able to successfully start mongodb again. I believe mine was still running from an improper shut down.

    0 讨论(0)
  • 2020-11-29 15:07

    I had a similar issue and followed all the instructions above regarding changing owners using sudo chown etc. I still had an instance of mongodb running in the background after the changes. Running

    ps auxw | grep mongo 
    

    showed me other tasks using mongo running in background that weren't closed properly. I then ran kill on all the ones running and then could start my server.

    0 讨论(0)
  • 2020-11-29 15:07

    For those of you experiencing this error on Windows using Task Manager end the instance of "mongod.exe" that is running. Once that is done permanently delete the mongo.lock file and run mongod.exe. It should work perfectly after that.

    0 讨论(0)
  • 2020-11-29 15:10

    In my case (AWS EC2 instance, Ubuntu) helped:

    $ sudo mkdir -p /data/db/
    $ sudo chown `USERNAME` /data/db
    

    And after that everything worked fine.

    0 讨论(0)
  • 2020-11-29 15:10

    My mongo (3.2.9) was installed on Ubuntu, and my log file had the following lines:

    2016-09-28T11:32:07.821+0100 E STORAGE  [initandlisten] WiredTiger (13) [1475058727:821829][6785:0x7fa9684ecc80], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied 
    2016-09-28T11:32:07.822+0100 I -        [initandlisten] Assertion: 28595:13: Permission denied 
    2016-09-28T11:32:07.822+0100 I STORAGE  [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating
    

    2016-09-28T11:32:07.822+0100 I CONTROL [initandlisten] dbexit: rc: 100

    So the problem was in permissions on /var/lib/mongodb folder.

    sudo chown -R mongodb:mongodb /var/lib/mongodb/
    sudo chmod -R 755 /var/lib/mongodb
    
    • Restart the server

    Fixed it, although I do realise that may be not too secure (it's my own dev box I'm in my case), bit following the change both db and authentication worked.

    0 讨论(0)
提交回复
热议问题