可以提供“代理"到每晚重新创建的 RDS 实例的连接信息? [英] Possible to provide "proxy" connection info to RDS instance that gets recreated nightly?

查看:26
本文介绍了可以提供“代理"到每晚重新创建的 RDS 实例的连接信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生产数据库(AWS RDS MySQL 实例),我的应用可以与之交互并收集各种数据.

I have a production DB (AWS RDS MySQL instance) that my app interacts with and that collects all sorts of data.

我被要求创建这个生产数据库的夜间快照,然后使用该快照创建一个新的数据库实例(从快照恢复),用作分析数据库和几个分析数据库工具将连接到它并针对它运行分析/报告.

I have been asked to create nightly snapshot of this production DB and then use that snapshot to create a new DB instance (restored from the snapshot) that will be used as an analytics DB and several analytical tools will connect to it and run analyses/reports against it.

出于此问题范围之外的原因,无法使用只读副本配置生产数据库,但是,可以解决我遇到的问题.这是...

For reasons outside the scope of this question, configuring the production DB with a read replica is not possible, but yes, that would solve the problem I have. Which is...

如果每天晚上我都是:

  1. 删除现有的分析数据库
  2. 创建生产数据库的快照
  3. 创建新的分析数据库
  4. 使用最新快照恢复新的分析数据库

...然后每晚分析工具都需要更新他们的连接信息,以便他们可以连接到新实例,这会变得很麻烦.用户名和密码和数据库名称将始终相同(每晚),但主机信息将更改,因为它始终是一个新的 RDS 实例.

...then every night the analytical tools will need their connection info to be updated so that they can connect to the new instance, and this will get cumbersome. The username and password and database name will always be the same (each night), but the host information will change since it will always be a new RDS instance.

同样,如果有一个专门的只读副本提供分析数据库,这里就不会有问题.我会一次性为我的分析工具提供只读副本的连接字符串信息,然后一切就绪.但同样,由于我无法控制的原因,无法使用只读副本解决方案.

Again, if there was a dedicated read replica feeding the analytics DB, there would be no problem here. I would provide my analytical tools with the read replica's connection string info one time and I'd be all set. But again, the read replica solution is not possible for reasons outside of my control.

所以我问:是否有任何 Route53、ELB 或其他AWS 魔法"?我可以用来给我的分析工具一个设置的主机名代理".以某种方式指向新的分析数据库(即使它每天晚上都被重新创建)?

So I ask: is there any Route53, ELB or other "AWS magic" I can use to give my analytical tools a set host name "proxy" that somehow points to the new analytics DB (even though its being re-created each and every night)?

推荐答案

我认为解决您的问题的一种方法是创建 私有托管区域 (PHZ) 与您的 VPC 关联的 Route53.使用 PHZ,您可以为代理创建别名记录,例如proxy.private.因此,您可以使用 proxy.private 代替 RDS 代理创建的默认网址.

I think one way to overcome your issue would involve creating private hosted zones (PHZ) in Route53 associated with your VPC. Using the PHZ you could create an alias record for your proxy, e.g. proxy.private. So you could use proxy.private in-place of a default url created by the RDS proxy.

当然,由于您每天都创建新的代理,因此必须更新 PHZ 中的记录,以便 proxy.private 指向新的代理 url.PHZ 中记录的更新取决于您每天如何设置新代理(使用 CloudForamtion、完全手动、lambda 函数等).

Off course, since you create new proxy every day, the record in the PHZ would have to be updated, so that proxy.private points to the new proxy url. The updated of the record in PHZ would depending on how you are setting up the new proxy everyday (using CloudForamtion, fully manual, lambda funcion, ...).

但最通用的方法是为 API 事件(需要 CloudTrail 跟踪)设置 EventBridge (EB) 规则,该规则将侦听与创建代理 (CreateDBProxy) 相关的 API 事件.EB 规则可以在响应 CreateDBProxy 事件时触发 lambda 函数,该函数将等待代理可用并自动更新记录.

But the most general way, would be to setup EventBridge (EB) rule for API events (CloudTrail trail required) which would listen for API events associated with creation of the proxy (CreateDBProxy). The EB rule could trigger a lambda function in a response to CreateDBProxy event which would wait for the proxy to be available and update the record automatically.

这篇关于可以提供“代理"到每晚重新创建的 RDS 实例的连接信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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