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'.
- First I ran
sudo service mongodb stop. - Then I used
ls -lato see what group & owner mongodb assigned to/var/lib/mongodb(existing path) and I changed the/data/db(new path) withchownandchgrpto match. (example:sudo chown -R mongodb:mongodb /data/db) - Then I updated the path in
etc/mongodb.confto/data/dband deleted the old mongo files in/var/lib/mongodbdirectory. - Then I ran
sudo service mongodb startand waited about a minute. If you try to connect to 27017 immediately you won't be able to. - After a minute check
/data/db(EBS volume) and mongo should have placed a journal, mongod.lock, local.ns, local.0, etc. If not trysudo service mongodb restartand 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:
本文介绍如何解决在Ubuntu EC2实例上迁移MongoDB数据路径时遇到的权限拒绝问题。通过调整文件所有者和组别设置,并修改配置文件中的路径指向新位置。

被折叠的 条评论
为什么被折叠?



