简体   繁体   English

无法在Mongodb Atlas端口上连接

[英]Not able to connect on Mongodb Atlas port

I'm using an M0 GCP instance. 我正在使用M0 GCP实例。

I can connect to the cluster using this string: 我可以使用以下字符串连接到集群:

'mongodb+srv://my_user:my_pass@my_cluster-mbsnz.gcp.mongodb.net/db?retryWrites=true&w=majority'

I'm trying to use another client where I need to pass host and port, but I can't connect. 我试图在需要传递主机和端口的地方使用另一个客户端,但是我无法连接。

I tried telnet to the port 27017, but for some reason I'm not able to connect directly on the port. 我尝试将telnet连接到端口27017,但是由于某些原因,我无法直接在端口上进行连接。

curl http://my_cluster-mbsnz.gcp.mongodb.net:27017
curl: (7) Failed to connect to my_cluster-mbsnz.gcp.mongodb.net port 27017: Connection timed out

or 要么

telnet my_cluster-mbsnz.gcp.mongodb.net 27017
Trying 185.82.212.199...
^C -> After a long time waiting

What might be wrong ? 可能是什么问题?

+srv urls use a DNS seed. +srv网址使用DNS种子。 On atlas, you can click into the cluster and you should be able to see the urls for your primary & your secondaries and use those urls to connect. 在图集上,您可以单击进入集群,您应该能够看到主要和辅助站点的URL,并使用这些URL进行连接。 You should also be able to use nslookup to get that info using part of that connection string, but it's probably simpler to just look up the urls through the UI. 您还应该能够使用nslookup来通过该连接字符串的一部分获取该信息,但是通过UI查找URL可能更简单。

https://docs.mongodb.com/manual/reference/connection-string/ https://docs.mongodb.com/manual/reference/connection-string/

In order to leverage the DNS seedlist, use a connection string prefix of mongodb+srv: rather than the standard mongodb:. 为了利用DNS种子列表,请使用mongodb + srv:的连接字符串前缀,而不要使用标准的mongodb:。 The +srv indicates to the client that the hostname that follows corresponds to a DNS SRV record. + srv向客户端指示后面的主机名对应于DNS SRV记录。 The driver or mongo shell will then query the DNS for the record to determine which hosts are running the mongod instances. 然后,驱动程序或mongo shell将在DNS中查询记录,以确定哪些主机正在运行mongod实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM