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

前端 未结 28 1442
执念已碎
执念已碎 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:01

    You just have to give access to your /data/db folder.

    Type sudo chown -R <USERNAME> /data/db, replace <USERNAME> by your username.

    You can find your username by typing whoami.

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

    As of today, I tried to get my way through the to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating, and tried all the answer posted above to solve this problem, hence nothing worked out by adding

    sudo chown -R mongodb:mongodb /data/db

    Unless I added my current user permission to the location path by

    sudo chown $USER /data/db

    Hope this helps someone. Also I just installed Mongo DB on my pi. Cheers!

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

    Fix: sudo mongod

    I had the same problem, running mongod with sudo privileges fixed it. Coming from a windows environment, I used just mongod to start the daemon, well it looks like we need the superuser privileges to access /data/db.

    You can also give non root users Read and Write permissions to that path. check answers above for a guide!

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

    In Mycase
    In mongodb version 2.6.11 default databse directory is /var/lib/mongodb/

    1. $ sudo chown -R id -u /var/lib/mongodb/

    2. $ sudo chown -R id -u /var/lib/mongodb/mongod.lock

    3. $ sudo /etc/init.d/mongod stop

    4. $ sudo /etc/init.d/mongod start

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

    After I killed mongod, I just had the same problem: couldn't start mongod.

    $> sudo kill `pidof mongod`
    

    2015-08-03T05:58:41.339+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/mongodbtest/replset/data/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

    After I delete the lock directly, I can restart the mongod process.

    $>  rm -rf /data/mongodbtest/replset/data/mongod.lock
    
    0 讨论(0)
  • 2020-11-29 15:04

    I was having the same problem on a Ubuntu ec2 instance. I was following this amazon article on page 7:

    http://d36cz9buwru1tt.cloudfront.net/AWS_NoSQL_MongoDB.pdf

    Mongodb path in /etc/mongodb.conf was set to /var/lib/mongodb (primary install location and working). When I changed to /data/db (EBS volume) I was getting 'errno:13 Permission denied'.

    1. First I ran sudo service mongodb stop.
    2. Then I used ls -la to see what group & owner mongodb assigned to /var/lib/mongodb (existing path) and I changed the /data/db (new path) with chown and chgrp to match. (example: sudo chown -R mongodb:mongodb /data/db)
    3. Then I updated the path in etc/mongodb.conf to /data/db and deleted the old mongo files in /var/lib/mongodb directory.
    4. Then I ran sudo service mongodb start and waited about a minute. If you try to connect to 27017 immediately you won't be able to.
    5. After a minute check /data/db (EBS volume) and mongo should have placed a journal, mongod.lock, local.ns, local.0, etc. If not try sudo service mongodb restart and check a minute later.

    I just spent over a hour with this. Changing the group and deleting the old files is probably not necessary, but that's what worked for me.

    This is a great video about mounting a ebs volume to ec2 instance:

    http://www.youtube.com/watch?v=gBII3o3BofU

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