如何在不同的可用区域中创建 Aurora 集群数据库实例?

时间:2020-12-30 03:28:42

标签: amazon-web-services amazon-aurora

我创建了一个 Aurora 集群 (postgresql 11),在 ap-southeast-2 区域(1 个写入器,2 个读取器)中有 3 个实例。我注意到作者在 AZ 2b 中,但两个读者在同一个 AZ 中,即 2a。如何让它们均匀分布到 3 个 AZ?

此集群的 cloudformation:

AuroraDBFirstInstance:
    Type: AWS::RDS::DBInstance
    Properties:
      DBInstanceClass: ${self:custom.postgresqlInstanceClass}
      Engine: aurora-postgresql
      EngineVersion: ${self:custom.postgresqlEngineVersion}
      DBClusterIdentifier: !Ref AuroraDBCluster
      PubliclyAccessible: ${self:custom.publiclyAccessible}

  AuroraDBSecondInstance:
    Type: AWS::RDS::DBInstance
    Properties:
      DBInstanceClass: ${self:custom.postgresqlInstanceClass}
      Engine: aurora-postgresql
      EngineVersion: ${self:custom.postgresqlEngineVersion}
      DBClusterIdentifier: !Ref AuroraDBCluster
      PubliclyAccessible: ${self:custom.publiclyAccessible}

  AuroraDBThirdInstance:
    Type: AWS::RDS::DBInstance
    Properties:
      DBInstanceClass: ${self:custom.postgresqlInstanceClass}
      Engine: aurora-postgresql
      EngineVersion: ${self:custom.postgresqlEngineVersion}
      DBClusterIdentifier: !Ref AuroraDBCluster
      PubliclyAccessible: ${self:custom.publiclyAccessible}

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以自行在 cloudformation 中指定可用区。如果您不指定子网,则 Aurora 将从您提供的子网组中随机选择可用区。


Type: AWS::RDS::DBInstance
Properties: 
  AllocatedStorage: String
  AllowMajorVersionUpgrade: Boolean
  AssociatedRoles: 
    - DBInstanceRole
  AutoMinorVersionUpgrade: Boolean
  AvailabilityZone: String
  BackupRetentionPeriod: Integer
  CACertificateIdentifier: String
  CharacterSetName: String
  CopyTagsToSnapshot: Boolean
  DBClusterIdentifier: String
  DBInstanceClass: String
  DBInstanceIdentifier: String
  DBName: String
  DBParameterGroupName: String
  DBSecurityGroups: 
    - String
  DBSnapshotIdentifier: String
  DBSubnetGroupName: String
  DeleteAutomatedBackups: Boolean
  DeletionProtection: Boolean
  Domain: String
  DomainIAMRoleName: String
  EnableCloudwatchLogsExports: 
    - String
  EnableIAMDatabaseAuthentication: Boolean
  EnablePerformanceInsights: Boolean
  Engine: String
  EngineVersion: String
  Iops: Integer
  KmsKeyId: String
  LicenseModel: String
  MasterUsername: String
  MasterUserPassword: String
  MaxAllocatedStorage: Integer
  MonitoringInterval: Integer
  MonitoringRoleArn: String
  MultiAZ: Boolean
  OptionGroupName: String
  PerformanceInsightsKMSKeyId: String
  PerformanceInsightsRetentionPeriod: Integer
  Port: String
  PreferredBackupWindow: String
  PreferredMaintenanceWindow: String
  ProcessorFeatures: 
    - ProcessorFeature
  PromotionTier: Integer
  PubliclyAccessible: Boolean
  SourceDBInstanceIdentifier: String
  SourceRegion: String
  StorageEncrypted: Boolean
  StorageType: String
  Tags: 
    - Tag
  Timezone: String
  UseDefaultProcessorFeatures: Boolean
  VPCSecurityGroups: 
    - String


有关每个属性的更好信息,您可以参考 cloudformation 模板文档。 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html

答案 1 :(得分:0)

您可以通过 DBSubnetGroupAvailabilityZone 控制数据库实例的放置。

以下是用于创建 DBSubnetGroup工作示例,该示例由 us-east-1 中 3 个不同可用区中的 3 个子网组成。要运行此示例,您唯一需要做的就是将 us-east-1aus-east-1bus-east-1c AZ 中的子网 ID 更改为您自己的子网 ID }}:

MyDBSubnetGroup