具有 Cloud Formation 和 AZ 问题的 RDS [英] RDS with Cloud Formation and AZ issues

查看:30
本文介绍了具有 Cloud Formation 和 AZ 问题的 RDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用云形成来创建一个包含 RDS 实例的设置.

I am using cloud formation to create a setup containing an RDS instance.

由于以下错误,我在创建 RDS 实例时遇到了一些困难:

I am having some difficulties creating the RDS Instance on the account of the following error:

数据库子网组不满足可用区覆盖要求.请添加子网以覆盖至少 2 个可用区.当前的覆盖范围:1

DB Subnet Group doesn't meet availability zone coverage requirement. Please add subnets to cover at least 2 availability zones. Current coverage: 1

问题是整个设置都在一个 AZ 上……我该怎么办?只是在不同的可用区中创建一个额外的子网,其中没有任何内容仅供 RDS 使用?

The problem is that the entire setup is on a single AZ... what am i supposed to do? just create an extra subnet in a different AZ that has nothing in it just for the RDS?

也许 AWS 可以通过某种方式自动创建该子网,让我远离那一团糟.我不想要那个额外的子网,也不想让我的用户为此选择另一个可用区造成负担.

Maybe there is some way AWS can create that subnet automatically and leave me out of that mess. I don't want that extra subnet and I don't want to burden my users with selecting another AZ just for this.

推荐答案

是的,即使对于完全包含在单个可用区 [AZ] 中的部署,您也必须在不同的可用区中创建一个额外的子网并将其包含在您的数据库中子网组.此要求的基本原理是支持高可用性多可用区部署,如 在 VPC 中使用数据库实例 RDS 用户指南部分:

Yes, even for a deployment entirely contained within a single Availability Zone [AZ], you must create an extra subnet in a different AZ and include it in your DB Subnet Group. The rationale for this requirement is to support high-availability Multi-AZ deployments, as noted in the Working with a DB Instance in a VPC section of the RDS User Guide:

对于多可用区部署,为一个区域中的两个或多个可用区定义子网允许 Amazon RDS 在需要时在另一个可用区中创建新的备用.即使对于单可用区部署,您也需要这样做,以防万一您想在某个时候将它们转换为多可用区部署.

For Multi-AZ deployments, defining a subnet for two or more Availability Zones in a region allows Amazon RDS to create a new standby in another Availability Zone should the need arise. You need to do this even for Single-AZ deployments, just in case you want to convert them to Multi-AZ deployments at some point.

至于不让您的用户为此选择另一个可用区造成负担,有一些方法可以实现这一点.例如,您可以使用 Fn::GetAZsFn::Select 内在函数.如果您允许用户选择主要可用区,您还需要一个 条件 以确保辅助 AZ 不等于所选的主要 AZ.

As for not burdening your users with selecting another AZ just for this, there are ways to accomplish this. For example, you could select a secondary AZ automatically using the Fn::GetAZs and Fn::Select intrinsic functions. If you allow the user to select the primary AZ, you'll also need a Condition to ensure the secondary AZ doesn't equal the primary AZ selected.

这是一个示例模板片段:

Here's an example template snippet:

Parameters:
  PrimaryAZ:
    Type: AWS::EC2::AvailabilityZone::Name
    Description: Primary AZ
Conditions:
  IsFirstPrimaryAZ:
    Fn::Equals:
    - !Ref PrimaryAZ
    - Fn::Select [0, {Fn::GetAZs: ""}]
Resources:
  Subnet1:
    Type: "AWS::EC2::Subnet"
    Properties:
      AvailabilityZone: !Ref PrimaryAZ
      # ...
  Subnet2:
    Type: "AWS::EC2::Subnet"
    Properties:
      AvailabilityZone:
        Fn::If:
        - IsFirstPrimaryAZ
        - Fn::Select [1, {Fn::GetAZs: ""}]
        - Fn::Select [0, {Fn::GetAZs: ""}]
      # ...

这篇关于具有 Cloud Formation 和 AZ 问题的 RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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