如何在 MongoDB Atlas 和 Google App Engine 标准环境节点应用程序之间建立对等互连 [英] How to establish peering between MongoDB Atlas and Google App Engine Standard Environment Node App

查看:55
本文介绍了如何在 MongoDB Atlas 和 Google App Engine 标准环境节点应用程序之间建立对等互连的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 MongoDB Atlas 和 Google 的默认"之间建立了对等连接.VPC 和连接被标记为活动"两端.

vpc 的 ip 范围在 MongoDB Atlas 中被列入白名单.

但是我在 google-app-engine 中托管的节点在访问 MongoDB 时仍然超时.

我使用 mongodb atlas 的连接 url 以(注意-pri")的形式进行对等连接:

mongodb+srv://:@-pri.rthhs.mongodb.net/?retryWrites=true&w=majority

我缺少哪个部分来建立连接?我需要 google vpc 连接器吗?>

感谢您的帮助!

解决方案

首先,请确保您运行的是 M10-Cluster 或更高版本!!!VPC 对等对 M0/M2/M5 不可用...

是的,您确实需要那个连接器!来自 Gcloud 的所有无服务器"服务(如标准环境中的 GAE)都需要它.

  1. 按照 这些说明.您可以使用 gcloud app describe

    找到 GAE-App 的当前区域
  2. 你的 app.yaml 必须像这样指向那个连接器

app.yaml

运行时:nodejs10vpc_access_connector:名称:projects/GCLOUD_PROJECT_ID/locations/REGION_WHERE_GAE_RUNS/connectors/NAME_YOU_ENTERED_IN_STEP_1

  1. 转到您的Atlas 项目,导航到网络访问并将您在步骤 1 中为连接器设置的 IP 范围列入白名单

  2. 您可能还需要将步骤 1 中 VPC 网络的 IP 范围列入白名单.您可以在 GCP 中导航到 VPC-Network ->防火墙

如果您对如何设置 Atlas 和 Gcloud 之间的 VPC-Peering 有疑问,请尝试 本教程.他们为 Kubernetes-Engine 做这件事(不需要连接器).但是从上面添加我的步骤有望成功.

I've set up the peering connection between MongoDB Atlas and Googles "default" VPC and the connection is labeled as "active" on both ends.

The ip range of the vpc is whitelisted in MongoDB Atlas.

But my node hosted in google-app-engine still gets timed out when accessing the MongoDB.

I use the connection url of mongodb atlas for peered connection in the form of (notice the "-pri"):

mongodb+srv://<username>:<password>@<my-cluster>-pri.rthhs.mongodb.net/<dbname>?retryWrites=true&w=majority

Which part am i missing to establich the connection? Do i need a google vpc connector?

Thanks for any help!

解决方案

First of all, make sure you are running M10-Cluster or above!!! VPC-peering is not available for M0/M2/M5...

And YES you do need that connector! All "Serverless"-Services from Gcloud (like GAE in standard environment) need it.

  1. create a connector in the same region as your GAE-App following these instructions. You can find the current region of your GAE-App with gcloud app describe

  2. your app.yaml has to point to that connector like this

app.yaml

runtime: nodejs10

vpc_access_connector:
  name: projects/GCLOUD_PROJECT_ID/locations/REGION_WHERE_GAE_RUNS/connectors/NAME_YOU_ENTERED_IN_STEP_1

  1. Go to your Atlas project, navigate to Network Access and whitelist the IP-range you set for the connector in Step 1

  2. You may also need to whitelist the IP-range from Step 1 for the VPC-Network. You can do that in GCP by navigating to VPC-Network -> Firewall

If you have questions about how to setup the VPC-Peering between Atlas and Gcloud try this tutorial. They do it for Kubernetes-Engine (no connector needed). But adding my steps from above will hopefully do the trick.

这篇关于如何在 MongoDB Atlas 和 Google App Engine 标准环境节点应用程序之间建立对等互连的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆