为什么我无法启动 mongodb

发布于 2024-11-03 09:24:37 字数 1626 浏览 1 评论 0原文

这是错误:

(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

桜花祭 2024-11-10 09:24:37

启动 MongoDB 的用户帐户需要对 /data/db/ 目录具有写入权限...您可以像这样更改...

这命令会将 /data/db/ 的所有者更改为正在使用的用户帐户。

$ sudo chown `id -u` /data/db
$ mongod 

如果 MongoDB 启动时仍然遇到问题,则需要删除 /data/ db/mongod.lock 然后对数据库运行修复...

mongod --repair

有关修复的更多信息命令此处

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.

$ sudo chown `id -u` /data/db
$ mongod 

If you still run into problems with MongoDB starting, you need to delete /data/db/mongod.lock and then run repair on your database ...

mongod --repair

More about the repair command here.

始终不够爱げ你 2024-11-10 09:24:37

sudo 调用 mongod 或更改 /data/db/mongod.lock 的权限,使其可供您写入。

Either sudo the call to mongod or change the permissions of /data/db/mongod.lock so that it is writable by you.

猫腻 2024-11-10 09:24:37

我通过在 mongodb ie 上执行 chown 解决了这个问题。

sudo chown -R mongodb:mongodb /data

这是因为,当您

ls -lrth /data
drwxr-xr-x 2 mongodb mongodb  6 Jan  5 02:31 journal
-rwxr-xr-x 1 mongodb mongodb  0 Jan  5 02:31 mongod.lock
drwxr-xr-x 2 ubuntu  root    24 May  8 20:02 configdb

希望这会有所帮助时。

I resolved this by doing a chown on mongodb ie.

sudo chown -R mongodb:mongodb /data

This is because, when you do

ls -lrth /data
drwxr-xr-x 2 mongodb mongodb  6 Jan  5 02:31 journal
-rwxr-xr-x 1 mongodb mongodb  0 Jan  5 02:31 mongod.lock
drwxr-xr-x 2 ubuntu  root    24 May  8 20:02 configdb

Hope this helps.

π浅易 2024-11-10 09:24:37

确保您没有运行 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.

茶花眉 2024-11-10 09:24:37

在这里,我是如何解决它的

  1. 删除锁定文件后,我使用 sudo mongod --repair --config=/etc/mongodb.conf 修复了它,
    之后我使用 ls -l /var/lib/mongodb/mongod.lock 检查了 mongod.lock 权限,
  2. 它显示 root 是锁定文件的所有者,所以我使用 将其更改回 mongodb sudo chown mongodb:mongodb /var/lib/mongodb/*
  3. 然后使用 sudo service mongodb restart 重新启动 mongodb 服务

Here, how i solved it

  1. After removing lock file I repaired it using sudo mongod --repair --config=/etc/mongodb.conf,
    After this I Checked mongod.lock permission using ls -l /var/lib/mongodb/mongod.lock
  2. it was showing root is owner of lock file, so i changed it back to mongodb using sudo chown mongodb:mongodb /var/lib/mongodb/*
  3. then restart mongodb service using sudo service mongodb restart
遥远的她 2024-11-10 09:24:37

在Mac OSX Yosemite上,使用brew进行标准安装后:

sudo chown -R `id -u` /data/db

如果它没有启动(检查是否没有挂起和阻塞连接):

lsof -i:27017

输出类似:

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mongod  16948 andi    8u  IPv4 0x883a71bc9412939d      0t0  TCP *:27017 (LISTEN)

获取PID的值并运行:

kill -9 <PID>

现在你应该能够启动 mongo 服务器:mongod 然后在单独的控制台窗口中使用 mongo 连接到它

On Mac OSX Yosemite after standard install with brew:

sudo chown -R `id -u` /data/db

if it not starts (check if there are no hanging and blocking connections):

lsof -i:27017

outputs something like:

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mongod  16948 andi    8u  IPv4 0x883a71bc9412939d      0t0  TCP *:27017 (LISTEN)

take value of PID and run:

kill -9 <PID>

now you should be able to start mongo server: mongod and then e.g in separate console window connect to it with mongo

小草泠泠 2024-11-10 09:24:37

如果您想拯救副本集的成员不要使用上述方法。请改用 中描述的过程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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文