当前位置: 首页 > 知识库问答 >
问题:

无法从GCP群集使用VPC对等互连连接到Mongo Atlas

东郭凯捷
2023-03-14

我正在尝试将在GCP库伯内特斯引擎集群上运行的Java应用程序与Mongo Atlas集群(M20)连接起来。以前,当我没有打开VPC Peering并且我使用常规连接字符串时,它运行良好。但我现在正在尝试使用VPC Peering,在我的GCP项目中使用defaultVPC网络。我按照https://docs.atlas.mongodb.com/security-vpc-peering/.中的步骤选择了192.168.0.0/18的Atlas CIDR(b/c“Atlas CIDR块必须至少是 /18”),并在链接GCP项目和Atlas集群后,将10.128.0.0/9添加到Atlas集群的IP白名单中(b/c它说这是GCP项目中自动的默认范围)。

我实际上能够通过mongo"mongoDB srv://通过Mongo shell连接

Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@a07fbd8. Client view of cluster state is {type=REPLICA_SET, servers=[{address=<cluster_name>-shard-00-00-pri.crum0.gcp.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=<cluster_name>-shard-00-01-pri.crum0.gcp.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=<cluster_new>-shard-00-02-pri.crum0.gcp.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]

可能的问题:

1) is it possible to connect from a GCP cluster at all (or perhaps, why is this cluster somehow not part of default VPC network)?
2) is there something wrong in the Atlas CIDR range or my IP whitelist range?

任何帮助都将不胜感激。


共有3个答案

何承
2023-03-14

除了上面用户1145925的回答外,我还必须在Mongo Atlas上列出GKE的Pod地址范围。

贾俊艾
2023-03-14

我猜您应该使用拆分地平线设置,或者您没有从应用程序到副本集配置中使用的主机名/IP地址的连接。

Atlas侧的白名单应反映应用程序用于连接的IP,如Atlas所示。

长孙阳州
2023-03-14

我最后做了两个改变来使它工作。第一个改变是我缺少的一个明确的要求。还不确定第二次改变是否绝对必要。

1) 我必须创建一个新的GCP群集,在其中,VPC本机(启用IP别名)默认启用。在我的旧群集中,此设置已禁用,并且我无法为正在运行的群集更改它。必须打开此设置才能解决问题。

2) 虽然我使用的是Mongo Java驱动程序3.11.1,但我确实耦合了nslookup命令,并认为使用较旧的驱动程序样式的连接URI字符串(即mongodb://

帮助执行以下操作的命令:

>> nslookup <cluster_name>-shard-00-00-pri.crum0.gcp.mongodb.net
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   <cluster_name>-shard-00-00-pri.crum0.gcp.mongodb.net
Address: 192.168.248.2
>> nslookup <cluster_name>-pri.crum0.gcp.mongodb.net
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
*** Can't find <cluster_name>-pri.crum0.gcp.mongodb.net: No answer
 类似资料:
  • 我们已经配置了mongo atlas存档并尝试在VPC对等互连的帮助下连接aws ec2。我们已经建立了vpc对等互连来连接主数据库,并且工作正常。但是在存档db连接的情况下,我们有连接问题,如果我们尝试使用ip白名单,那么它可以正常工作。 有人能帮我们将mongo archive db与vpc对等连接起来吗。 与mongo shell连接时出错 2020-12-12T05:41:15.283 0

  • 我试图在我本地minikube集群上的一个简单示例中使用fabric8io/kubernetes-client,在这里我获得了一个pod的IP 是完成执行的pod的名称,如果执行则可见。 是一个kubernetes API主机,我从中获得该主机。 MiniKube只有1个节点。 Fabric8IO/Kubernetes-客户端版本为4.9.1 Java 11 我将此代码作为作业部署在的同一集群上。

  • 我正在尝试从MAC连接到安全的Azure Service Fabric群集,但我遇到了一些SSL问题 我可以通过Web浏览器通过相同的证书验证 /Explorer,但当我尝试与我的命令行相同,我得到SSl错误。有什么建议吗? 错误: 请求中出错,SSLError:HTTPSConnectionPool(host='mylinuxx.centralindia.cloudapp.azure.com',

  • 我正在尝试将GCP应用程序引擎上运行的nodejs应用程序连接到Mongo Atlas,但我收到网络错误。我已经设置了VPC对等,启用了无服务器VPC连接器,并在app yaml中添加了VPC\u access\u连接器属性,并在Atlas中列出了连接器的IP范围。我看到的确切错误是 我的代码是

  • 我尝试了kafka-console-consumer.sh和kafka-console-producer.sh,它工作得很好。我能够看到生产者在消费者中发送的消息 1)我已经下载了s3连接器(https://docs.confluent.io/current/connect/kafka-connect-S3/index.html) 2)将文件解压缩到/home/ec2-user/plugins/

  • 我有: > MongoDB Atlas集群 GCP之间的VPC对等。 当我尝试从我的家用笔记本电脑连接到DB时: 我收到一个错误: 我看到收到的本地IP地址,但我不明白如何连接到私有VPC中的我的数据库? 我将非常高兴能得到任何帮助!