无法连接到MongoDB [英] Unable to connect to MongoDB

查看:322
本文介绍了无法连接到MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了MongoDB(标准的Ubuntu版本,不是最新的稳定版),由于某种原因我无法连接:

I've just installed MongoDB (standard Ubuntu build, not the latest stable) and for some reason I can't connect:

Mon Feb  6 03:11:22 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
exception: connect failed

现在我的机器不是127.xx1,它是出于某种原因xxx2(但是我更改了配置以绑定到该地址,并且还尝试绑定到我的公共IP,但无济于事.

Now my machine isn't 127.x.x.1 it's for some reason x.x.x.2 (But i've changed my config to bind to that address, and also tried to bind to my public IP which provided no avail.

配置:

#mongodb.conf

#mongodb.conf

# Where to store the data.

# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

bind_ip = 199.21.114.XX
port = 27017

我已经检查了日志,并且其中仅显示启动信息.

I've checked the logs and only startup info is displaying in there.

我还检查了守护进程是否也在运行,而且-我什至尝试使用--fork手动运行它.

I've also checked that the deamon is running too, and it is - I even tried running it manually with a --fork.

有没有人遇到过这个?或有什么建议吗?

Has anyone come across this before? Or any suggestions?

Thx

更新:

重启后-这是日志:

** WARNING: You are running in OpenVZ. This is known to be broken!!!

Tue Feb  7 19:43:32 [initandlisten] db version v1.8.2, pdfile version 4.5
Tue Feb  7 19:43:32 [initandlisten] git version: nogitversion
Tue Feb  7 19:43:32 [initandlisten] build sys info: Linux allspice 2.6.24-28-se$
Tue Feb  7 19:43:32 [initandlisten] *** warning: spider monkey build without ut$
Tue Feb  7 19:43:32 [initandlisten] waiting for connections on port 27017
Tue Feb  7 19:43:32 [websvr] web admin interface listening on port 28017

推荐答案

您必须通过运行mongo 199.21.114.XX指定IP(199.21.114.XX).

You must specify the IP (199.21.114.XX), by running mongo 199.21.114.XX.

否则,如果您还希望它也在localhost上侦听,则应删除配置文件中的bind_ip设置.

Otherwise, if you want it to listen on localhost as well, you should remove the bind_ip setting in your config file.

更新.检查您的防火墙配置.由于您正在连接到外部IP,因此可以将其配置为阻止,甚至可以从本地设备阻止.

Update Check your firewall config. Since you're connecting to the external IP, it can be configured to block, even from the local box.

这篇关于无法连接到MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆