[英]Mongo: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
When I try to run mongo in shell in ubuntu or open rockmongo I see this error: 当我尝试在ubuntu中运行mongo或打开rockmongo时,我看到了这个错误:
couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
What's the reason? 什么原因? I tried to reinstall mongo but this didn't help.
我试图重新安装mongo,但这没有帮助。 When I type
sudo apt-get purge mongodb-10gen
returned error is 当我键入
sudo apt-get purge mongodb-10gen
返回错误是
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried this: 我试过这个:
run this commands: 运行以下命令:
sudo dpkg pr mongofb-10gen
sudo apt-get -f install
sudo apt-get upadte
sudo apt-get upgrade
sudo dpkg pr mongofb-10gen
sudo apt-get -f install
sudo apt-get upadte
sudo apt-get upgrade
then sudo apt-get purge mongodb-10gen
is successful 然后
sudo apt-get purge mongodb-10gen
成功了
at the end: 在末尾:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen in /etc/apt/sources.list 在/etc/apt/sources.list中添加deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
sudo apt-get update
sudo apt-get install mongodb-10gen
sudo apt-get update
sudo apt-get install mongodb-10gen
Then when I try to start mongo i saw the same error. 然后,当我尝试启动mongo时,我看到了同样的错误。 :o
:○
I assume that you followed the steps, outlined here . 我假设你按照这里概述的步骤进行操作。
Most probably you have a problem with mongo lock (or at least I had it once while installing on ubuntu). 很可能你有mongo锁的问题(或者至少我在ubuntu上安装时曾经有过一次)。 I solved it with the following commands:
我用以下命令解决了它:
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart
PS I by myself recently experienced this problem when I was updating my amazon ec2
instance. PS I我自己最近在更新我的
amazon ec2
实例时遇到了这个问题。 I have not properly shut down mongo before doing this and this resulted in a problem with mongo lock. 在执行此操作之前,我没有正确关闭mongo,这导致mongo锁定问题。
Check your log file of mongodb. 检查mongodb的日志文件。 you will get to know the exact issue.
你会知道确切的问题。
tail -f /var/log/mongodb/mongodb.log
The issue may because of "ERROR: Insufficient free space for journal files" 问题可能是因为“错误:日志文件的可用空间不足”
Increase your volume space that will fix your issue. 增加容量空间以解决问题。
如果你在重新启动后得到这个...确保你有超过3GB +的空间,否则Mongo将无法启动。
even i had the same problem so i deleted the mongod lock file 即使我有同样的问题,所以我删除了mongod锁文件
sudo rm /var/lib/mongodb/mongod.lock
and the restart the server it worked , restarting by command below 并重新启动它工作的服务器,通过下面的命令重新启动
sudo service mongodb restart
i got the solution by changing the owner of db directory to 'mongodb' 我通过将db目录的所有者更改为'mongodb'来获得解决方案
`sudo chown -R mongodb:mongodb /data/*`
then type 'mongo' 然后键入'mongo'
我想你无法连接到mongodb的原因是计算机驱动器上的空间不足。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.