如何从 Google 的标准 App Engine (Python 3.7) 连接到 Redis 实例 (memorystore) [英] How to connect to Redis instance (memorystore) from Google's Standard App Engine (Python 3.7)

查看:51
本文介绍了如何从 Google 的标准 App Engine (Python 3.7) 连接到 Redis 实例 (memorystore)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从 App Engine 实例连接到 Redis 实例,但没有任何运气.我的连接超时.

I've been trying to get a connect to a Redis instance from an App Engine instance without any luck. I get a connection time out.

我已经在 app.yaml 中设置了主机和端口:

I've set the host and port in my app.yaml:

env_variables:
  REDIS_HOST: '10.0.0.3'
  REDIS_PORT: '6379'

并尝试按照示例中的说明进行连接:

And try to connect as specified in the examples:

redis_host = os.environ.get('REDIS_HOST', 'localhost')
redis_port = int(os.environ.get('REDIS_PORT', 6379))
redis_client = redis.StrictRedis(host=redis_host, port=redis_port)

但它不起作用,某些文档似乎需要 en vpc 访问连接器,但这些仅在 us-cental1 中可用,我同时获得了 App Engine 实例和Memorystore (Redis) 在 asia-northeast1 中运行.

But it's not working, some documentation seem to want en vpc access connector, but those are only available in the us-cental1 and I got both the App Engine instances & Memorystore (Redis) running in asia-northeast1.

有没有人有幸让这个工作?总的来说,谷歌非常擅长记录他们的东西,但对我来说这似乎缺乏,真的没有关于如何让它工作的明确文档.

Has anyone had any luck getting this working? In general google's pretty good at documenting their stuff but this seems lacking to me, there's really no clear documentation on how to get it working.

推荐答案

您可以在其他区域使用 VPC 连接器,但只能使用 gcloud 命令行.在 GUI 上,只有 us-central1 可用.

You can use VPC connector in other region, but only with the gcloud command line. On the GUI, only us-central1 is available.

这篇关于如何从 Google 的标准 App Engine (Python 3.7) 连接到 Redis 实例 (memorystore)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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