首页 > 解决方案 > Rds_instance 无法使用 Ansible 在 Aurora 集群中创建 RDS 数据库

问题描述

我正在尝试创建一个具有 1 个写入器/读取器节点的 Aurora 数据库集群。

Ansible 目前似乎不支持为 Aurora 创建集群,所以我使用 AWS CLI 创建它。

#NOTE - Currently, Ansible does not support creating an RDS cluster in the official documentation.  This may change in the future.
- name: Create the DB cluster
  command: >
    aws rds create-db-cluster
      --db-cluster-identifier production-db
      --engine aurora-mysql
      --db-subnet-group-name webserver-connections
      --vpc-security-group-ids sg-dja17283
      --storage-encrypted
      --db-cluster-parameter-group-name my-parameter-group
      --master-username "my_username"
      --master-user-password "My_Password"
      --backup-retention-period 7
  when: aurora_cluster == ''


- name: Create instances inside of cluster
  rds_instance:
    engine: aurora
    engine_version: "5.7.mysql_aurora.2.07.2"
    db_instance_identifier: ansible-test-aurora-db-instance
    instance_type: db.t2.small
    cluster_id: production-db
    multi_az: yes
    storage_encrypted: yes
   # backup_retention_period: 7
    tags:
      Environment: "Production"

这返回 -

"msg": "Unable to create DB instance: An error occurred (InvalidParameterCombination) when calling the CreateDBInstance operation: Cannot find version 5.7.mysql_aurora.2.07.2 for aurora",

如果我将引擎设置为aurora-mysql,我会看到以下内容 -

"msg": "Unable to create DB instance: An error occurred (InvalidParameterCombination) when calling the CreateDBInstance operation: VPC Multi-AZ DB Instances are not available for engine: aurora-mysql"

当取消注释备份保留期(它在初始集群创建 CLI 调用以及播放中定义)时,我看到以下内容 -

"msg": "Unable to create DB instance: An error occurred (InvalidParameterCombination) when calling the CreateDBInstance operation: The requested DB Instance will be a member of a DB Cluster. Set backup retention period for the DB Cluster.

是否可以使用 Ansible 创建 Aurora-Mysql 多可用区 RDS 集群?通过阅读文档,它似乎还不受支持。

是否可以使用 Ansible 管理集群内的数据库实例,例如多 az aurora-mysql 部署中的读取器/写入器节点?如果是这样,我该怎么做?我所有的测试都返回了与上述类似的结果。

谢谢。

标签: amazon-web-servicesansible

解决方案


我不确定 Ansible 是否支持 Aurora,但所有这些错误消息都是有效的。

您需要更改engineaurora-mysql,并将其删除multi-az或设置为,false因为multi-az它不是可用的 Aurora 功能。

Multi-az 在另一个可用区中创建 RDS 服务器的第二个“备份”实例。由于 Aurora 是一个集群而不是单实例系统,因此您只需自己创建第二个实例,而不是指定multi-az.


推荐阅读