为什么我无法启动 mongodb
这是错误:
(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
this is the error:
(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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
启动 MongoDB 的用户帐户需要对
/data/db/
目录具有写入权限...您可以像这样更改...这命令会将
/data/db/
的所有者更改为正在使用的用户帐户。如果 MongoDB 启动时仍然遇到问题,则需要删除
/data/ db/mongod.lock
然后对数据库运行修复...有关修复的更多信息命令此处。
The user account that is starting MongoDB needs to have write privileges to the
/data/db/
directory ... you can change this like so ...This command will change the owner of the
/data/db/
to the user account being used.If you still run into problems with MongoDB starting, you need to delete
/data/db/mongod.lock
and then run repair on your database ...More about the repair command here.
sudo
调用mongod
或更改/data/db/mongod.lock
的权限,使其可供您写入。Either
sudo
the call tomongod
or change the permissions of/data/db/mongod.lock
so that it is writable by you.我通过在 mongodb ie 上执行 chown 解决了这个问题。
这是因为,当您
希望这会有所帮助时。
I resolved this by doing a chown on mongodb ie.
This is because, when you do
Hope this helps.
确保您没有运行 mongod 实例。
这对我有用。我首先通过在终端中查看是否有一个实例在后台运行,如下所示:
辅助 | grep mongo
,我看到有:
48358 bla bla mongod
所以我杀了它:
杀死 48358
然后我就可以正常运行它了。
Make sure you do not have a mongod instance running.
This is what worked for me. I checked to see if there was an instance running in the background at first by looking in the terminal like this:
ps aux | grep mongo
and I saw that there was:
48358 bla bla mongod
so I killed it:
kill 48358
and then I was able to run it fine.
在这里,我是如何解决它的
之后我使用 ls -l /var/lib/mongodb/mongod.lock 检查了 mongod.lock 权限,
将其更改回 mongodb sudo chown mongodb:mongodb /var/lib/mongodb/*
sudo service mongodb restart
重新启动 mongodb 服务Here, how i solved it
sudo mongod --repair --config=/etc/mongodb.conf
,After this I Checked mongod.lock permission using
ls -l /var/lib/mongodb/mongod.lock
sudo chown mongodb:mongodb /var/lib/mongodb/*
sudo service mongodb restart
在Mac OSX Yosemite上,使用brew进行标准安装后:
如果它没有启动(检查是否没有挂起和阻塞连接):
输出类似:
获取
PID
的值并运行:现在你应该能够启动 mongo 服务器:
mongod
然后在单独的控制台窗口中使用mongo
连接到它On Mac OSX Yosemite after standard install with brew:
if it not starts (check if there are no hanging and blocking connections):
outputs something like:
take value of
PID
and run:now you should be able to start mongo server:
mongod
and then e.g in separate console window connect to it withmongo
如果您想拯救副本集的成员不要使用上述方法。请改用 中描述的过程ReSync-MongoDB 文档。
If you want to rescue a member of a replica set don't use this methods described above. Instead use the procedures described in the ReSync-documentation of MongoDB.