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
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
.
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!
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!
In Mycase
In mongodb version 2.6.11 default databse directory is /var/lib/mongodb/
$ sudo chown -R id -u
/var/lib/mongodb/
$ sudo chown -R id -u
/var/lib/mongodb/mongod.lock
$ sudo /etc/init.d/mongod stop
$ sudo /etc/init.d/mongod start
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
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'.
sudo service mongodb stop
.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
)etc/mongodb.conf
to /data/db
and deleted the old mongo files in /var/lib/mongodb
directory.sudo service mongodb start
and waited about a minute. If you try to connect to 27017 immediately you won't be able to./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