【问题标题】:Restore RDS Snapshot from console or CLI is way faster than cloudformation?从控制台或 CLI 还原 RDS 快照比 cloudformation 快得多?
【发布时间】:2019-11-19 01:11:00
【问题描述】:

我正在编写一些自动化程序来创建我的 AWS 生产环境的副本,以供开发人员和 QA 进行测试。我正在使用 bash 脚本调用带有 AWS Cloudformation 模板的 AWS cli。

当我使用 Cloudformation 执行此操作时,它会创建数据库,然后 RDS 会花费 7 个小时使用“将修改应用于分配的存储”日志对其进行修改,直到 CloudFormation 因“DBInstance testaedb 未稳定”而失败并开始回滚,这也失败了。

如果我从控制台创建相同的 RDS 实例,使用相同的参数,大约需要 7 分钟来创建 RDS 实例并变为活动状态。我今天早上刚刚运行了一个测试,如果我使用 CLI 工具创建它也是如此。

这里是 CloudFormation 模板 sn-p:

  AccountsRds:
    Type: 'AWS::RDS::DBInstance'
    Properties:
      DBInstanceIdentifier: !Sub '${EnvName}aedb'
      DBSnapshotIdentifier: !Sub '${AccountsSnapshot}'
      DBInstanceClass: 'db.t3.xlarge'
      DBSubnetGroupName:
        Fn::ImportValue:
          !Sub '${NetworkStackName}-RdsSubnetGroupId'
      AutoMinorVersionUpgrade: 'true'
      PubliclyAccessible: 'false'
      VPCSecurityGroups:
      - !GetAtt AccountsRdsSecurityGroup.GroupId

这里是 CLI sn-p:

aws rds restore-db-instance-from-db-snapshot \
 --region ${AE_REGION} \
 --db-instance-identifier "${AE_ENV_NAME}"aedb \
 --db-snapshot-identifier ${AE_DB_SNAPSHOT_ID} \
 --db-instance-class db.t3.xlarge \
 --db-subnet-group-name ${AE_DB_SUBNET_GROUP_NAME} \
 --no-publicly-accessible \
 --auto-minor-version-upgrade \
 --vpc-security-group-ids ${AE_DB_SECURITY_GROUP}

我预计 CloudFormattation 和 CLI 会花费相同的时间。知道为什么 Cloudformation 需要 7 个小时吗?我的数据库没有那么大,250GB。

【问题讨论】:

  • 快照是从具有预置 IOPS 的实例制作的吗?
  • 不是。它来自一个只有标准 SSD 的实例。

标签: amazon-web-services amazon-cloudformation aws-cli


【解决方案1】:

AWS 支持人员已确定问题的根本原因。根据他们的说法,RDS 实例的默认 StorageType 因配置方式而异:

  • CLI 命令:gp2
  • Web 控制台:gp2
  • CloudFormation:磁盘

因此,它失败了,因为磁盘的性能不足以处理快照还原。

解决方案是在您的 Cloudformation 模板中简单地包含 StorageType,它将以与 CLI 命令相似的速度进行配置。

【讨论】:

    猜你喜欢
    • 2018-10-10
    • 2017-03-02
    • 2014-08-08
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2015-11-22
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多