如何在不同可用区创建极光集群数据库实例?
How can I create aurora cluster db instance in different available zone?
我在 ap-southeast-2 区域(1 位写入者,2 位 reader)创建了一个包含 3 个实例的 Aurora 集群 (postgresql 11)。我注意到作者在 AZ 2b
中,但两个 reader 在同一个 AZ 中,即 2a
。我怎样才能让它们均匀分布到 3 个可用区?
此集群的 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}
您可以在cloudformation中自行指定AZ。如果您不指定子网,Aurora 将从您提供的子网组中随机选择 AZ。
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
您可以通过 DBSubnetGroup and AvailabilityZone.
控制数据库实例的放置
下面是 工作 示例,用于创建 DBSubnetGroup
,其中包含 us-east-1
中 3 个不同 AZ 中的 3 个子网。 运行 这个例子你唯一需要做的就是 将 subnet-ids 从 us-east-1a
, us-east-1b
,us-east-1c
MyDBSubnetGroup
中的可用区:
Resources:
MyDBSubnetGroup:
Properties:
DBSubnetGroupDescription: Subent Group in 3 AZs
SubnetIds:
- subnet-82c876e5
- subnet-21ef547d
- subnet-a9e16487
Type: "AWS::RDS::DBSubnetGroup"
RDSCluster:
Properties:
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora-postgresql
MasterUserPassword: postgresql22332
MasterUsername: postgresql
Type: "AWS::RDS::DBCluster"
RDSDBInstance1:
Properties:
AvailabilityZone: us-east-1a
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"
RDSDBInstance2:
Properties:
AvailabilityZone: us-east-1b
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"
RDSDBInstance3:
Properties:
AvailabilityZone: us-east-1c
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"
我在 ap-southeast-2 区域(1 位写入者,2 位 reader)创建了一个包含 3 个实例的 Aurora 集群 (postgresql 11)。我注意到作者在 AZ 2b
中,但两个 reader 在同一个 AZ 中,即 2a
。我怎样才能让它们均匀分布到 3 个可用区?
此集群的 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}
您可以在cloudformation中自行指定AZ。如果您不指定子网,Aurora 将从您提供的子网组中随机选择 AZ。
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
您可以通过 DBSubnetGroup and AvailabilityZone.
控制数据库实例的放置下面是 工作 示例,用于创建 DBSubnetGroup
,其中包含 us-east-1
中 3 个不同 AZ 中的 3 个子网。 运行 这个例子你唯一需要做的就是 将 subnet-ids 从 us-east-1a
, us-east-1b
,us-east-1c
MyDBSubnetGroup
中的可用区:
Resources:
MyDBSubnetGroup:
Properties:
DBSubnetGroupDescription: Subent Group in 3 AZs
SubnetIds:
- subnet-82c876e5
- subnet-21ef547d
- subnet-a9e16487
Type: "AWS::RDS::DBSubnetGroup"
RDSCluster:
Properties:
DBSubnetGroupName: !Ref MyDBSubnetGroup
Engine: aurora-postgresql
MasterUserPassword: postgresql22332
MasterUsername: postgresql
Type: "AWS::RDS::DBCluster"
RDSDBInstance1:
Properties:
AvailabilityZone: us-east-1a
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"
RDSDBInstance2:
Properties:
AvailabilityZone: us-east-1b
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"
RDSDBInstance3:
Properties:
AvailabilityZone: us-east-1c
DBClusterIdentifier:
Ref: RDSCluster
DBInstanceClass: db.t3.medium
Engine: aurora-postgresql
PubliclyAccessible: "true"
DeleteAutomatedBackups: true
Type: "AWS::RDS::DBInstance"