MongoDB to Google Cloud Platform VPC无法正常工作

问题描述 投票:0回答:1

我遵循了this指南来设置VPC,以允许从我的GCP项目到MongoDB Atlas数据库的流量。

  1. 在Atlas上设置VPC

enter image description here

  1. 将个人计算机和GCP列入白名单

enter image description here

  1. 在GCP上创建VPC

enter image description here

  1. 本地测试

Works

  1. 设置虚拟机

enter image description here

  1. SSH到虚拟机并测试登录:
...

2020-04-01T04:15:59.926+0000 I NETWORK  [js] DBClientConnection failed to receive message from shard...mongodb.net.:27017 - HostUnreachable: Connection closed by peer
    2020-04-01T04:15:59.927+0000 W NETWORK  [js] Unable to reach primary for set shard...
*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.


    2020-04-01T04:15:59.927+0000 E QUERY    [js] Error: connect failed to replica set shard.../shard...mongodb.net.:27017,shard...mongodb.net.:27017,shard...mongodb.net.:27017 :
    connect@src/mongo/shell/mongo.js:344:17
    @(connect):2:6
    exception: connect failed
mongodb google-cloud-platform vpc mongodb-atlas
1个回答
0
投票

请遵循官方文档https://docs.atlas.mongodb.com/security-vpc-peering/index.html

  1. 请确保您的GCP专用网络的CIDR范围不应与Atlas CIDR重叠,因为在这种情况下,VPC对等也将不起作用。

  2. 但是,如果紧急,您可以在Atlas中将您的公共IP列入白名单并使其正常运行。

要使其运行,请添加带有CIDR范围,安全组,路由表的GCP控制台的屏幕快照。

© www.soinside.com 2019 - 2024. All rights reserved.