本文介绍了无法从第二个VM实例连接到Google Compute Engine上的MongoDB服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个Ubuntu 16 VM上安装了MongoDb,这两个VM都托管在Google Cloud Compute Engine的同一网络上.连接实例的内部IP为10.132.0.2,数据库实例的IP为10.132.0.3.( https://gyazo.com/59f9086591a1d6673e8194a50fff51e1 )

I have MongoDb installed on two Ubuntu 16 VMs both hosted on the same network on Google Cloud's Compute Engine. The connecting instance has Internal IP 10.132.0.2, the database instance has 10.132.0.3.(https://gyazo.com/59f9086591a1d6673e8194a50fff51e1)

我已经为要连接的实例打开了tcp 27017.我使用gcloud控制台命令添加了它.( https://gyazo.com/0d158aa735c6967e278fac63d598721f )我还尝试过打开tcp:1-65535; udp:1-65535进行测试,但没有结果.

I've opened tcp 27017 for the instance I wish to connect to. I added this using the gcloud console commands.(https://gyazo.com/0d158aa735c6967e278fac63d598721f)I have also tried opening tcp:1-65535;udp:1-65535 for testing purposes, with no result.

在任何一个实例上运行mongo都会正确连接到它自己的mongodb服务,因此它们已安装,正在运行且正在运行.

Running mongo on either instance will properly connect to it's own mongodb service, so they're installed, running and working.

在数据库实例上,netstat -a | grep :27017显示其正在正确侦听.( https://gyazo.com/0f4fb3c49a51f6886ff4ccb2d44a132a )

On the database instance, netstat -a | grep :27017 displays that it's listening correctly.(https://gyazo.com/0f4fb3c49a51f6886ff4ccb2d44a132a)

在数据库实例上,位于的/etc/mongod.conf处的配置文件被编辑,因此bind_ip也具有该实例的内部IP.( https://gyazo.com/20fb669506e7e67ef49fdcf9af6df144 )我还尝试了0.0.0.0进行测试,但没有结果.

On the database instance, the config file at /etc/mongod.conf of the is edited so bind_ip also has the Internal IP of said instance.(https://gyazo.com/20fb669506e7e67ef49fdcf9af6df144)I have also tried 0.0.0.0 for testing purposes, with no result.

从连接实例中运行mongo 10.132.0.3会导致Failed to connect to 10.132.0.3:27017, reason: errno:111 Connection refused.( https://gyazo.com/9e5aec732e3f09cbfa62a4d78df3620f )

Running mongo 10.132.0.3 from the connecting instance results in Failed to connect to 10.132.0.3:27017, reason: errno:111 Connection refused.(https://gyazo.com/9e5aec732e3f09cbfa62a4d78df3620f)

在连接实例上运行nmap -p 27017 10.132.0.3表示端口27017已关闭.( https://gyazo.com/7ccd905db5b9946d616176b9ab75479c )

Running nmap -p 27017 10.132.0.3 on the connecting instance shows port 27017 is closed.(https://gyazo.com/7ccd905db5b9946d616176b9ab75479c)

我很茫然,请帮帮我吗? :<

I'm at an utter loss, please help me out? :<

推荐答案

感谢E. Anderson的链接,我设法解决了这个问题;突然变成了重复.但是,此答案或链接中的答案均不是正确".

Thanks to E. Anderson's link I managed to solve this issue; suddenly turning this into a duplicate. However, neither this answer nor the answer in the link were "correct".

mongod.conf中设置bind_ip=0.0.0.0的解决方案非常危险,而且没有用.但是,杀死mongodb服务,然后手动运行mongod --bind_ip 10.132.0.3实际上允许我的两个实例连接.

The solution to set bind_ip=0.0.0.0 in mongod.conf is rather dangerous, besides, it didn't work. However, killing the mongodb service, and then manually running mongod --bind_ip 10.132.0.3 actually allowed my two instances to connect.

这意味着..在另一个线程中javadude的回复说"But I still dont get it. Why this did not work when I modified mongo.conf文件接受bind_ip 0.0.0.0`也对我有用. -地址来收听.

Which.. means that javadude's reply in the other thread saying "But I still dont get it. Why this did not work when I modified mongo.conf file to accept bind_ip 0.0.0.0"` also goes for me. I don't get it, but, it definitely worked to manually give it an ip-address to listen on.

这篇关于无法从第二个VM实例连接到Google Compute Engine上的MongoDB服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:55