2

我在尝试启动 mongodb 时遇到问题,下面我将向您显示错误:

    xxx@xxx [/var/lib/mongo]# /etc/init.d/mongod start
    Starting mongod: all output going to: /var/log/mongo/mongod.log
                                                           [FAILED]

在 mongod.log 上看到我收到以下通知:

***** SERVER RESTARTED *****


Thu Mar 21 12:10:20.860 [initandlisten] MongoDB starting : pid=19148 port=27017 dbpath=/var/lib/mongo 64-bit host=srv1.canoa.net
Thu Mar 21 12:10:20.860 [initandlisten] db version v2.4.0
Thu Mar 21 12:10:20.860 [initandlisten] git version: ce2d666c04b4a80af58e8bbb3388b0680e8cfeb6
Thu Mar 21 12:10:20.860 [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
Thu Mar 21 12:10:20.861 [initandlisten] allocator: tcmalloc
Thu Mar 21 12:10:20.861 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid" }
Thu Mar 21 12:10:20.861 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Mar 21 12:10:20.861 dbexit:
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: going to close listening sockets...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: going to flush diaglog...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: going to close sockets...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: waiting for fs preallocator...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: lock for final commit...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: final commit...
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: closing all files...
Thu Mar 21 12:10:20.861 [initandlisten] closeAllFiles() finished
Thu Mar 21 12:10:20.861 [initandlisten] shutdown: removing fs lock...
Thu Mar 21 12:10:20.861 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Mar 21 12:10:20.861 dbexit: really exiting now

引起我注意的是:

Thu Mar 21 12:10:20.861 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

/var/lib/mongo 里面的文件夹和文件有 0755 权限。

如果有人能告诉我这样做的方法,我将不胜感激。

4

3 回答 3

5

我解决了错误,这是因为我只将mongod用户分配给/var/lib/mongo而不是其中的文件,以下命令解决了这部分:chown -R mongod:mongod /var/lib/mongo.

然后只需要用用户mongod使用以下命令修复数据库:sudo -u mongod mongod -f /etc/mongod.conf --repair,我终于成功启动了数据库。

我希望这对其他人有帮助。

谢谢大家的答案。

于 2013-03-21T18:22:06.950 回答
2

也许上次mongod进程被错误终止时,尝试删除mongo.lock它应该会有所帮助

于 2013-03-21T16:54:51.093 回答
0

我假设您正在以 root身份运行service mongodb start/stop/restart/status命令?.. 使用 sudo 吗?如果我尝试以普通用户身份启动它,我会收到该错误。

于 2013-03-21T17:42:35.590 回答