本文介绍了Mongo:无法在src/mongo/shell/mongo.js:145连接到服务器127.0.0.1:27017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在ubuntu的shell中运行mongo或打开rockmongo时,我看到此错误:

When I try to run mongo in shell in ubuntu or open rockmongo I see this error:

couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145

是什么原因?我试图重新安装mongo,但这无济于事.当我键入sudo apt-get purge mongodb-10gen时,返回错误是

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

E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试过:

  • 首先在/etc/apt/sources.list中删除有关mongo的行
  • 运行以下命令:

  • first remove line about mongo in /etc/apt/sources.list
  • run this commands:

sudo dpkg pr mongofb-10gensudo apt-get -f installsudo apt-get upadtesudo apt-get upgrade

然后sudo apt-get purge mongodb-10gen成功

最后:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

添加deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen在/etc/apt/sources.list

add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10genin /etc/apt/sources.list

sudo apt-get updatesudo apt-get install mongodb-10gen

然后,当我尝试启动mongo时,我看到了相同的错误. :o

Then when I try to start mongo i saw the same error. :o

推荐答案

我假设您已按照此处.

很可能您的mongo锁有问题(或者至少在ubuntu上安装时遇到了一次).我用以下命令解决了这个问题:

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:

sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart

PS .我最近在更新我的amazon ec2实例时遇到了这个问题.在执行此操作之前,我没有正确关闭mongo,这导致mongo lock出现问题.

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.

这篇关于Mongo:无法在src/mongo/shell/mongo.js:145连接到服务器127.0.0.1:27017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:40