如何让 mongo 在 ec2 上使用已安装的驱动器?我真的不明白。我在 ec2 上附加了一个卷,将驱动器格式化为 root 并以 root 身份启动,但作为 root 我无法访问?我在 ubuntu 12.04 上运行。没有其他 mongo 正在运行
我看到 mongo 在 /data 即 /data/db 中创建了一个“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
下面是如果我在删除锁定文件时重新启动....
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 页关注这篇亚马逊文章:
http://d36cz9buwru1tt.cloudfront.net/AWS_NoSQL_MongoDB.pdf
Mongodb 路径/etc/mongodb.conf设置为/var/lib/mongodb(主要安装位置和工作)。当我更改为/data/db(EBS 卷)时,我收到“errno:13 Permission denied”。
/etc/mongodb.conf
/var/lib/mongodb
/data/db
sudo service mongodb stop
ls -la
chown
chgrp
sudo chown -R mongodb:mongodb /data/db
etc/mongodb.conf
sudo service mongodb start
sudo service mongodb restart
我刚刚花了一个多小时。更改组和删除旧文件可能不是必需的,但这对我有用。