Linux Mongo:无法在 src/mongo/shell/mongo.js:145 连接到服务器 127.0.0.1:27017
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19527564/
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
Mongo: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
提问by micobg
When I try to run mongo in shell in ubuntu or open rockmongo I see this error:
当我尝试在 ubuntu 中的 shell 中运行 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. When I type sudo apt-get purge mongodb-10gen
returned error is
什么原因?我试图重新安装 mongo 但这没有帮助。当我输入sudo apt-get purge mongodb-10gen
返回的错误是
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried this:
我试过这个:
- first remove line about mongo in /etc/apt/sources.list
run this commands:
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 successfulat the end:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstartdist 10gen in /etc/apt/sources.list
sudo apt-get update
sudo apt-get install mongodb-10gen
- 首先删除 /etc/apt/sources.list 中关于 mongo 的行
运行这个命令:
sudo dpkg pr mongofb-10gen
sudo apt-get -f install
sudo apt-get upadte
sudo apt-get upgrade
然后
sudo apt-get purge mongodb-10gen
成功在末尾:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
在 /etc/apt/sources.list 中添加 deb http://downloads-distro.mongodb.org/repo/ubuntu-upstartdist 10gen
sudo apt-get update
sudo apt-get install mongodb-10gen
Then when I try to start mongo i saw the same error. :o
然后当我尝试启动 mongo 时,我看到了同样的错误。:o
采纳答案by Salvador Dali
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). I solved it with the following commands:
很可能你有 mongo lock 的问题(或者至少我在 ubuntu 上安装时遇到过一次)。我用以下命令解决了它:
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart
P.S.I by myself recently experienced this problem when I was updating my amazon ec2
instance. I have not properly shut down mongo before doing this and this resulted in a problem with mongo lock.
PS我自己最近在更新amazon ec2
实例时遇到了这个问题。在执行此操作之前,我没有正确关闭 mongo,这导致 mongo 锁出现问题。
回答by arulraj.net
Check your log file of mongodb. you will get to know the exact issue.
检查您的 mongodb 日志文件。您将了解确切的问题。
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.
增加将解决您的问题的卷空间。
回答by codemeasandwich
If you got this after a restart... Make sure that you have over 3GB+ of space free else Mongo Won't start.
如果你在重启后得到这个......确保你有超过 3GB 的可用空间,否则 Mongo 将无法启动。
回答by Shafin M Salam
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'
回答by user3470929
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
回答by shenlu
I guess the reason why you cannot connect to mongodb is the insufficient space in the drive on your computer.
我猜您无法连接到mongodb的原因是您的计算机驱动器中的空间不足。