无法创建/打开锁定文件:/data/mongod.lock errno:13 权限被拒绝 [英] Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied
问题描述
如何让 mongo 在 ec2 上使用已安装的驱动器?我真的不明白.我在 ec2 上附加了一个卷,将驱动器格式化为 root 并以 root 启动,但作为 root 我无法访问?我在 ubuntu 12.04 上运行.没有其他 mongo 正在运行
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 cant access? I am running on ubuntu 12.04. No other mongo is running
我看到 mongo 在/data 即/data/db 中创建了一个 'db' 目录
I see that mongo made a 'db' dir in /data i.e. /data/db
cd /
ls -al
drwxr-xr-x 4 root root 4096 Mar 5 16:28 data
cd /data
ls -al
total 28
drwxr-xr-x 4 root root 4096 Mar 5 16:28 .
drwxr-xr-x 24 root root 4096 Mar 5 16:28 ..
drwxr-xr-x 2 root root 4096 Mar 5 16:28 db
drwx------ 2 root root 16384 Mar 5 16:20 lost+found
sudo mkfs.ext3 /dev/xvdh
sudo mkdir /data
sudo su - -c 'echo "/dev/xvdh %s auto noatime 0 0" | sudo tee -a /etc/fstab'
sudo mount /data
sudo service mongodb start
mongodb start/running, process 17169
sudo ps -ef | grep mongod
ubuntu 15763 15634 0 16:32 pts/2 00:00:00 tail -f mongodb.log
ubuntu 18049 15766 0 16:43 pts/3 00:00:00 grep --color=auto mongod
Tue Mar 5 16:33:15 [initandlisten] MongoDB starting : pid=15890 port=27017 dbpath=/data 64-bit host=aws-mongo-server-east-staging-20130305161917
Tue Mar 5 16:33:15 [initandlisten] db version v2.2.3, pdfile version 4.5
Tue Mar 5 16:33:15 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Tue Mar 5 16:33:15 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Mar 5 16:33:15 [initandlisten] options: { bind_ip: "10.157.60.27", config: "/etc/mongodb.conf", dbpath: "/data", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", replSet: "heythat" }
Tue Mar 5 16:33:15 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Tue Mar 5 16:33:15 dbexit:
Tue Mar 5 16:33:15 [initandlisten] shutdown: going to close listening sockets...
Tue Mar 5 16:33:15 [initandlisten] shutdown: going to flush diaglog...
Tue Mar 5 16:33:15 [initandlisten] shutdown: going to close sockets...
Tue Mar 5 16:33:15 [initandlisten] shutdown: waiting for fs preallocator...
Tue Mar 5 16:33:15 [initandlisten] shutdown: lock for final commit...
Tue Mar 5 16:33:15 [initandlisten] shutdown: final commit...
Tue Mar 5 16:33:15 [initandlisten] shutdown: closing all files...
Tue Mar 5 16:33:15 [initandlisten] closeAllFiles() finished
Tue Mar 5 16:33:15 [initandlisten] shutdown: removing fs lock...
Tue Mar 5 16:33:15 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Tue Mar 5 16:33:15 dbexit: really exiting now
下面是如果我在删除锁定文件时重新启动....
Below is if I restart when I remove a lock file....
Tue Mar 5 16:59:15 [initandlisten] MongoDB starting : pid=21091 port=27017 dbpath=/data 64-bit host=aws-mongo-server-east-staging-20130305161917
Tue Mar 5 16:59:15 [initandlisten] db version v2.2.3, pdfile version 4.5
Tue Mar 5 16:59:15 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Tue Mar 5 16:59:15 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Mar 5 16:59:15 [initandlisten] options: { bind_ip: "10.157.60.27", config: "/etc/mongodb.conf", dbpath: "/data", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", replSet: "heythat" }
Tue Mar 5 16:59:15 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Tue Mar 5 16:59:15 dbexit:
Tue Mar 5 16:59:15 [initandlisten] shutdown: going to close listening sockets...
Tue Mar 5 16:59:15 [initandlisten] shutdown: going to flush diaglog...
Tue Mar 5 16:59:15 [initandlisten] shutdown: going to close sockets...
Tue Mar 5 16:59:15 [initandlisten] shutdown: waiting for fs preallocator...
Tue Mar 5 16:59:15 [initandlisten] shutdown: lock for final commit...
Tue Mar 5 16:59:15 [initandlisten] shutdown: final commit...
Tue Mar 5 16:59:15 [initandlisten] shutdown: closing all files...
Tue Mar 5 16:59:15 [initandlisten] closeAllFiles() finished
Tue Mar 5 16:59:15 [initandlisten] shutdown: removing fs lock...
Tue Mar 5 16:59:15 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Tue Mar 5 16:59:15 dbexit: really exiting now
推荐答案
我在 Ubuntu ec2 实例上遇到了同样的问题.我正在关注第 7 页上的这篇亚马逊文章:
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
/etc/mongodb.conf
中的 Mongodb 路径被设置为 /var/lib/mongodb
(主要安装位置和工作).当我更改为 /data/db
(EBS 卷)时,我收到errno:13 Permission denied".
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
看看是什么组&所有者 mongodb 分配给/var/lib/mongodb
(现有路径),我用chown
更改了/data/db
(新路径)和chgrp
匹配.(例如:sudo chown -R mongodb:mongodb/data/db
) - 然后我将
etc/mongodb.conf
中的路径更新为/data/db
并删除了/var/lib/mongodb中的旧mongo文件
目录. - 然后我运行
sudo service mongodb start
并等待了大约一分钟.如果您尝试立即连接到 27017,您将无法连接. - 一分钟后检查
/data/db
(EBS卷)和mongo应该已经放置了一个日志,mongod.lock,local.ns,local.0等.如果没有尝试sudo service mongodb restart
一分钟后检查.
- First I ran
sudo service mongodb stop
. - 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) withchown
andchgrp
to match. (example:sudo chown -R mongodb:mongodb /data/db
) - Then I updated the path in
etc/mongodb.conf
to/data/db
and deleted the old mongo files in/var/lib/mongodb
directory. - 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. - 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 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.
这是一个关于将 ebs 卷安装到 ec2 实例的精彩视频:
This is a great video about mounting a ebs volume to ec2 instance:
http://www.youtube.com/watch?v=gBII3o3BofU
这篇关于无法创建/打开锁定文件:/data/mongod.lock errno:13 权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!