无法在 Ubuntu 11.04 上重新启动 mongodb
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10072563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot restart mongodb on Ubuntu 11.04
提问by Amila
I have installed mongodb and when i typing the following command i am getting these messages
我已经安装了 mongodb,当我输入以下命令时,我收到了这些消息
root@amila:~# service mongodb status
mongodb stop/waiting
root@amila:~# service mongodb restart
restart: Unknown instance:
root@amila:~# service mongodb stop
stop: Unknown instance:
I want to restart mongodb.but unable to restart.
我想重新启动 mongodb。但无法重新启动。
EDIT: here is the /etc/mongodb.conf
编辑:这里是/etc/mongodb.conf
dbpath=/var/lib/mongodb logpath=/var/log/mongodb/mongodb.log
dbpath=/var/lib/mongodb logpath=/var/log/mongodb/mongodb.log
logappend=true
日志附加=真
bind_ip = 127.0.0.1
auth = true
bind_ip = 127.0.0.1
认证 = 真
回答by Adam Comerford
Given the output of the start command, this is starting correctly. When you are running status, it seems to have been stopped. You need to look into the log file:
鉴于 start 命令的输出,这是正确启动。当你处于运行状态时,它似乎已经停止了。您需要查看日志文件:
/var/log/mongodb/mongodb.log
That will tell you why the mongod is stopping. There are a couple of likely causes, but without seeing that output it will be hard to answer definitively. My general recommendations:
这会告诉你为什么 mongod 会停止。有几个可能的原因,但如果没有看到输出,就很难明确回答。我的一般建议:
Do not use bind_ip - it is a bad idea in generalUpdate (2016): Removing this because the issues with bind_ip that caused me to write this back in 2012 have been fixed, and it is even on by default in official packages now. Worth trying without the setting as a troubleshooting step, but not a bad idea to use it in general.- Check for something else running on port 27017
- Specify the port explicitly in the mongodb.conf file, even if you want to use the default
不要使用 bind_ip - 一般情况下这是个坏主意更新 (2016):删除它是因为导致我在 2012 年写回的 bind_ip 问题已经修复,现在官方软件包中甚至默认启用它。值得尝试在没有设置的情况下作为故障排除步骤,但通常使用它并不是一个坏主意。- 检查端口 27017 上运行的其他内容
- 在 mongodb.conf 文件中明确指定端口,即使你想使用默认的
Finally, take a look at this answer for how to fix file permissions, just in case that is a problem (usually caused by running as root at some point):
最后,看看这个关于如何修复文件权限的答案,以防万一这是一个问题(通常是由在某些时候以 root 身份运行引起的):
回答by warran
Sorry if you consider this "SO archeology".
对不起,如果你考虑这个“SO考古学”。
I don't know if this is the same issue, but I'm facing something similiar right now. End of my log:
我不知道这是否是同一个问题,但我现在面临类似的问题。我的日志结束:
Mon Nov 19 10:25:37 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Mon Nov 19 10:25:37 dbexit:
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to close listening sockets...
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to flush diaglog...
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to close sockets...
Mon Nov 19 10:25:37 [initandlisten] shutdown: waiting for fs preallocator...
Mon Nov 19 10:25:37 [initandlisten] shutdown: lock for final commit...
Mon Nov 19 10:25:37 [initandlisten] shutdown: final commit...
Mon Nov 19 10:25:37 [initandlisten] shutdown: closing all files...
Mon Nov 19 10:25:37 [initandlisten] closeAllFiles() finished
Mon Nov 19 10:25:37 dbexit: really exiting now
So I think the lock file is not closed properly (for example when shutting down). You should use
所以我认为锁文件没有正确关闭(例如在关闭时)。你应该使用
mongod --repair
But it didn't work for me, so I just removed /var/lib/mongodb/mongod.lock
and then started the server. This is not the secure way, and there is possibility, that data in your database is corrupt if you do so.
但它对我不起作用,所以我只是删除/var/lib/mongodb/mongod.lock
然后启动了服务器。这不是安全的方法,如果这样做,数据库中的数据可能会损坏。
回答by tattooedgeek
Sorry to rehash this thread, but I'm putting this here because I ran into the exact same issue and this worked.
很抱歉重新讨论这个线程,但我把它放在这里是因为我遇到了完全相同的问题并且这有效。
taken from here:
取自这里:
sudo -u mongodb mongod --repair -dbpath /var/lib/mongodb
I'm running linux mint 15 and current mongodb build.
我正在运行 linux mint 15 和当前的 mongodb 版本。
回答by Andrea Turri
I had the same problem and I solved running just:
我有同样的问题,我解决了运行:
$ service mongod restart
$ service mongod restart
回答by MatteoM
I solved this manually deleting .lock file like that
我解决了这个手动删除 .lock 文件
sudo rm -i /var/lib/mongodb/mongod.lock
须藤 rm -i /var/lib/mongodb/mongod.lock
then restart
然后重新启动
回答by Deep Kapadia
Looks like Mongo is unable to start for some reason. Apart from the suggestions already provided by Adam.
看起来 Mongo 由于某种原因无法启动。除了亚当已经提供的建议。
- Check to see if you have write permissions to the data directory.
- Check to see if you have write permissions to the /var/log directory.
- Is mongod running as root or as another user? Check the init script for mongodb to see what user is mongod running as.
- 检查您是否具有对数据目录的写权限。
- 检查您是否对 /var/log 目录具有写权限。
- mongod 是以 root 身份运行还是以其他用户身份运行?检查 mongodb 的 init 脚本以查看运行 mongod 的用户。
回答by kartikmaji
One of the possible cases might be mongod.lock(which was causing my problem).
可能的情况之一可能是 mongod.lock (这导致了我的问题)。
Open your log file at
打开您的日志文件在
/var/log/mongodb/mongod.log
/var/log/mongodb/mongod.log
See if you have any exception because of mongod.lock file. Copy it's location and remove it
看看你是否因为 mongod.lock 文件有任何异常。复制它的位置并将其删除
sudo rm /var/lib/mongodb/mongod.lock
须藤rm /var/lib/mongodb/mongod.lock
Then run
然后运行
sudo service mongod restart
须藤服务 mongod 重启
To check if everything is fine now.
检查现在是否一切正常。
sudo service mongod status
须藤服务 mongod 状态
Expected output will be mongod start/running
预期输出将是 mongod start/running
回答by Victor Igbokwe
Sometimes the problems can be caused by not having enough free storage for journaling
to continue smoothly.
有时,问题可能是由于没有足够的可用存储空间journaling
来继续顺利进行。
Did a tail -100 /var/log/mongodb/mongod.log
and found this error:
做了一个tail -100 /var/log/mongodb/mongod.log
,发现这个错误:
exception in initAndListen: 15926 Insufficient free space for journals, terminating
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles`
exception in initAndListen: 15926 Insufficient free space for journals, terminating
请在 /var/lib/mongodb/journal 中至少提供 3379MB 可用空间或使用 --smallfiles`
Resolved it by putting smallfiles=true
in my MongoDB config file /etc/mongod.conf
.
通过放入smallfiles=true
我的 MongoDB 配置文件来解决它/etc/mongod.conf
。
Then sudo rm /var/lib/mongodb/mongod.lock
然后 sudo rm /var/lib/mongodb/mongod.lock
And then restarting the MongoDB instance using service mongod start
然后使用重新启动MongoDB实例 service mongod start
Hope this help.
希望这有帮助。