如何连接到 MongoDB EC2 实例 [英] How to connect to MongoDB EC2 instance

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

问题描述

我们有一个来自 Amazon MarketPlace 的 EC2 MongoDB 2.4 实例.当我尝试使用 mongo 命令从我的计算机访问它时:

we have an EC2 MongoDB 2.4 instance from Amazon MarketPlace. when i try to access it from my computer using the mongo command like so:

mongo xx-xx-xx-xx-xx.compute-1.amazonaws.com

我收到以下错误

Error: couldn't connect to server xx-xx-xx-xx-xx.compute-1.amazonaws.com:27017 at src/mongo/shell/mongo.js:147
exception: connect failed

  • 我可以使用 ssh 连接到远程实例,因此可以访问.
  • 端口是默认端口 27017.
  • mongod 正在远程实例上运行和工作.
  • 有关如何解决此问题的任何建议?

    any suggestions on how to fix this?

    推荐答案

    正如 frisky 所说,您必须在 EC2 安全组控制台上打开端口 27017.(要了解有关如何执行此操作的更多信息:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html)

    As frisky said, you have to open the port 27017 at the EC2 Security Group Console. (To know more about how to do that: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html)

    但您还需要更改/etc/mongodb.conf 文件中的 bind_ip 变量.您需要注释该行或分配能够将数据库连接到它的 IP.

    But you also need to change the bind_ip variable at the /etc/mongodb.conf file. You need to comment the line or assign the ip that will be able to connect the DB to it.

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

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