MongoDB无法启动
无法连接到mongodb。
$ mongo
MongoDB shell version: 2.6.3
connecting to: test
2015-07-06T16:37:10.218+0900 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-07-06T16:37:10.219+0900 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
如果强制终止,会留下一个名为 mongod.lock 的文件,导致无法启动。
解决方案 ‘àn)
删除 mongod.lock 文件,然后执行 mongod –repair。
解決未能实现
$ sudo mongod --repair
~
*********************************************************************
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
2015-07-06T17:04:45.439+0900 [initandlisten] dbexit:
2015-07-06T17:04:45.439+0900 [initandlisten] shutdown: going to close listening sockets...
2015-07-06T17:04:45.439+0900 [initandlisten] shutdown: going to flush diaglog...
2015-07-06T17:04:45.439+0900 [initandlisten] shutdown: going to close sockets...
2015-07-06T17:04:45.439+0900 [initandlisten] shutdown: waiting for fs preallocator...
2015-07-06T17:04:45.439+0900 [initandlisten] shutdown: closing all files...
2015-07-06T17:04:45.440+0900 [initandlisten] closeAllFiles() finished
2015-07-06T17:04:45.440+0900 [initandlisten] dbexit: really exiting now
出现了”/data/db”目录不存在的错误。
参考了这里的说明,我创建了原来数据的存储位置和符号链接。
mongod -dbpath /usr/local/var/mongodb
再次解决
mongod启动后执行mongo命令,连接成功
仅提供一种选项: 参考
以下为两个链接的本土化中文重述:
链接1:http://azwoo.hatenablog.com/entry/2014/04/19/224644
链接2:http://qiita.com/hidesuke/items/56a87d827708c8c770da