如何在亚马逊AWS VPC私有子网中打开Mongo端口 [英] How to open mongo port in amazon aws vpc private subnet
问题描述
我按如下所述设置VPC: http://docs.amazonwebservices. com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html
I setup the VPC as described here: http://docs.amazonwebservices.com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html
我在私有子网中有一个框,想用作mongo框.专用IP为10.0.1.51.
And I have a box in the private subnet, that I want to use as a mongo box. The private IP is 10.0.1.51.
我可以通过localhost连接到mongod实例,但不能通过私有IP:
I can connect to mongod instance over localhost, but not over the private IP:
ubuntu@ip-10-0-1-51:~$ mongo localhost
connecting to: localhost
> this works
> ^Cubuntu@ip-10-0-1-51:~$ mongo 10.0.1.51
Fri Sep 21 02:23:18 Error: couldn't connect to server 10.0.1.51 shell/mongo.js:81
exception: connect failed
ubuntu@ip-10-0-1-51:~$
安全组允许传入和传出端口27017.
The security group allows incoming and outgoing port 27017.
路由表具有
10.0.0.0/16 local
进入.
我想念什么?
推荐答案
问题实际上出在mongodb配置中,而不是路由表中.像MySQL一样,MongoDB需要允许来自特定主机的连接.
The problem was actually in mongodb config, not the routing tables. MongoDB, like MySQL, needs to allow connections from a specific host.
在mongodb.conf中:
In mongodb.conf:
bind_ip = <%= @bind_ip || '127.0.0.1' %>
port = <%= @port || '27017' %>
@bind_ip
和@port
是服务器在客户端节点上显示的IP和端口.
Where @bind_ip
and @port
are the IP and port of your server as it appears to the client nodes.
这篇关于如何在亚马逊AWS VPC私有子网中打开Mongo端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!