新手问题 MongoDB 自启动一直失败

newnewnew · 2013年05月12日 · 最后由 syling1 回复于 2013年05月13日 · 7929 次阅读

rc.local 中加入 mongodb 启动命令:

/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db/ --logpath=/usr/local/mongodb/log/mongodb.log --logappend --fork

重启服务器后 mongo 客户端链接失败 查看 log 日志 错误如下

Sun May 12 18:37:35.658 [initandlisten] MongoDB starting : pid=963 port=27017 dbpath=/usr/local/mongodb/data/db/ 64-bit host=AY1304122154200811e8
Sun May 12 18:37:35.658 [initandlisten] db version v2.4.3
Sun May 12 18:37:35.658 [initandlisten] git version: fe1743177a5ea03e91e0052fb5e2cb2945f6d95f
Sun May 12 18:37:35.658 [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
Sun May 12 18:37:35.658 [initandlisten] allocator: tcmalloc
Sun May 12 18:37:35.658 [initandlisten] options: { dbpath: "/usr/local/mongodb/data/db/", fork: true, journal: true, logpath: "/usr/local/mongodb/log/mongodb.log" }
Sun May 12 18:37:35.703 [initandlisten] journal dir=/usr/local/mongodb/data/db/journal
Sun May 12 18:37:35.705 [initandlisten] recover : no journal files present, no recovery needed
Sun May 12 18:37:35.844 [initandlisten] waiting for connections on port 27017
Sun May 12 18:37:35.844 [websvr] admin web console waiting for connections on port 28017
Sun May 12 18:39:02.513 [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
Sun May 12 18:39:02.513 [signalProcessingThread] now exiting
Sun May 12 18:39:02.513 dbexit:
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: going to close listening sockets...
Sun May 12 18:39:02.513 [signalProcessingThread] closing listening socket: 9
Sun May 12 18:39:02.513 [signalProcessingThread] closing listening socket: 10
Sun May 12 18:39:02.513 [signalProcessingThread] closing listening socket: 11
Sun May 12 18:39:02.513 [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: going to flush diaglog...
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: going to close sockets...
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: waiting for fs preallocator...
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: lock for final commit...
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: final commit...
Sun May 12 18:39:02.513 [signalProcessingThread] shutdown: closing all files...
Sun May 12 18:39:02.513 [signalProcessingThread] closeAllFiles() finished
Sun May 12 18:39:02.513 [signalProcessingThread] journalCleanup...
Sun May 12 18:39:02.513 [signalProcessingThread] removeJournalFiles
Sun May 12 18:39:02.542 [signalProcessingThread] shutdown: removing fs lock...
Sun May 12 18:39:02.542 dbexit: really exiting now

然后在我指定的 dbpath 目录中 (usr/local/mongodb/data/db/) 啥也没生成... 请问怎么解决啊...😢

你这个数据库已经启动了,应该是连接不上而已,如果是用 rails 连接的话,看看 rails log 里报什么错。dbpath 里什么都没有因为你没往数据库里写东西啊。

data 目录下有一个 mongod.lock 文件,把这个文件删掉,然后再次启动就可以了。我之前遇到和你一样的问题,在网上搜到这个方法,但是不知道什么原因,但用这个方法的确可以解决。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号