昨天我已将Ubuntu 14.10升级到15.04。但这导致我停止工作。我正在研究chicagoboss和mongodb。我看到mongodb坠毁的错误。 通过输入只是mongo得到以下错误:
$ mongo
MongoDB shell version: 2.4.10
connecting to: test
Mon May 11 11:26:32.985 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
关注stackoverflow query并删除了.lock
文件。然后尝试使用
$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
*********************************************************************
我发现在我的mongodb.conf文件中dbpath
是/var/lib/mongodb
。在我找到所有mongodb数据库的地方哪个是正确的。所以我尝试将dbpath设置为相同的位置,但收到错误:
$ mongod --dbpath "/var/lib/mongodb"
Mon May 11 11:33:18.607 [initandlisten] MongoDB starting : pid=4450 port=27017 dbpath=/var/lib/mongodb 64-bit host=laxmikant-alphonso
Mon May 11 11:33:18.607 [initandlisten] db version v2.4.10
Mon May 11 11:33:18.607 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a
Mon May 11 11:33:18.607 [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
Mon May 11 11:33:18.607 [initandlisten] allocator: tcmalloc
Mon May 11 11:33:18.607 [initandlisten] options: { dbpath: "/var/lib/mongodb" }
Mon May 11 11:33:18.607 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Mon May 11 11:33:18.607 dbexit:
Mon May 11 11:33:18.607 [initandlisten] shutdown: going to close listening sockets...
Mon May 11 11:33:18.607 [initandlisten] shutdown: going to flush diaglog...
Mon May 11 11:33:18.607 [initandlisten] shutdown: going to close sockets...
Mon May 11 11:33:18.607 [initandlisten] shutdown: waiting for fs preallocator...
Mon May 11 11:33:18.607 [initandlisten] shutdown: lock for final commit...
Mon May 11 11:33:18.607 [initandlisten] shutdown: final commit...
Mon May 11 11:33:18.607 [initandlisten] shutdown: closing all files...
Mon May 11 11:33:18.608 [initandlisten] closeAllFiles() finished
Mon May 11 11:33:18.608 [initandlisten] shutdown: removing fs lock...
Mon May 11 11:33:18.608 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Mon May 11 11:33:18.608 dbexit: really exiting now
如何解决此问题。我想要恢复所有数据库。
此外,我检查了service start
我是否收到了以下错误:
$ sudo service mongodb start
Failed to start mongodb.service: Unit mongodb.service failed to load: No such file or directory.
答案 0 :(得分:1)
$ mongod --dbpath "/var/lib/mongodb"
在这种情况下,您将mongodb作为自己启动。并且您可能没有数据目录的R / W权限。
$ sudo service mongodb start
现在你启动mongodb作为服务,它可能会将其身份从root更改为“mongo”或类似的东西。在类似debian的系统上,mongodb的配置在/etc/init/mongodb.conf
或最好在/etc/mongodb.conf
。见http://packages.ubuntu.com/utopic/amd64/mongodb-server/filelist。在那里你可以change the database path。
顺便说一下,检查数据目录的权限。用户“mongo” - 或者什么应该有写访问权限:
$ ls -l /var/lib/mongodb