这是错误:
(mysite)zjm1126@zjm1126-G41MT-S2:~$ /usr/local/mongodb/bin/mongod /usr/local/mongodb/bin/mongod --help for help and startup options Wed Apr 27 10:02:41 [initandlisten] MongoDB starting : pid=2652 port=27017 dbpath=/data/db/ 32-bit ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data ** see http://blog.mongodb.org/post/137788967/32-bit-limitations ** with --dur, the limit is lower Wed Apr 27 10:02:41 [initandlisten] db version v1.8.1, pdfile version 4.5 Wed Apr 27 10:02:41 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04 Wed Apr 27 10:02:41 [initandlisten] build sys info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37 Wed Apr 27 10:02:41 [initandlisten] exception in initAndListen std::exception: Unable to create / open lock file for lockfilepath: /data/db/mongod.lock errno:13 Permission denied, terminating Wed Apr 27 10:02:41 dbexit: Wed Apr 27 10:02:41 [initandlisten] shutdown: going to close listening sockets... Wed Apr 27 10:02:41 [initandlisten] shutdown: going to flush diaglog... Wed Apr 27 10:02:41 [initandlisten] shutdown: going to close sockets... Wed Apr 27 10:02:41 [initandlisten] shutdown: waiting for fs preallocator... Wed Apr 27 10:02:41 [initandlisten] shutdown: closing all files... Wed Apr 27 10:02:41 closeAllFiles() finished Wed Apr 27 10:02:41 [initandlisten] shutdown: removing fs lock... Wed Apr 27 10:02:41 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor Wed Apr 27 10:02:41 dbexit: really exiting now
Justin Jenki.. 87
启动MongoDB的用户帐户需要具有该目录的写权限/data/db/
...您可以这样更改...
此命令将更改/data/db/
所使用的用户帐户的所有者.
$ sudo chown `id -u` /data/db $ mongod
如果仍然遇到启动MongoDB的问题,则需要删除/data/db/mongod.lock
然后在数据库上运行修复...
mongod --repair
更多关于修复命令的信息.
启动MongoDB的用户帐户需要具有该目录的写权限/data/db/
...您可以这样更改...
此命令将更改/data/db/
所使用的用户帐户的所有者.
$ sudo chown `id -u` /data/db $ mongod
如果仍然遇到启动MongoDB的问题,则需要删除/data/db/mongod.lock
然后在数据库上运行修复...
mongod --repair
更多关于修复命令的信息.
无论是sudo
在通话mongod
或更改的权限/data/db/mongod.lock
,以便它是你写的.
我通过在mongodb上做了一个chown来解决这个问题.
sudo chown -R mongodb:mongodb /data
这是因为,当你这样做
ls -lrth /data drwxr-xr-x 2 mongodb mongodb 6 Jan 5 02:31 journal -rwxr-xr-x 1 mongodb mongodb 0 Jan 5 02:31 mongod.lock drwxr-xr-x 2 ubuntu root 24 May 8 20:02 configdb
希望这可以帮助.
确保没有运行mongod实例.
这对我有用.我首先通过查看终端来检查是否在后台运行了一个实例:ps aux | grep mongo
我看到有:48358 bla bla mongod
所以我杀了它:杀掉48358
然后我就能运行得很好.