CloudFormation 中的 Redis 多可用区功能

Redis Multi-AZ feature in CloudFormation

我正在设计一个包含 Redis 服务的模板,我想在 Redis 中启用多可用区功能,以便在主集群发生故障时,只读副本可以提升为主集群。我查看了 CloudFormation 文档,但找不到此功能,即多可用区。它适用于 RDS 服务,但不适用于 Redis。我可以知道如何为 redis 添加功能,以便 AWS 负责自动故障转移吗?

来源: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticache-cache-cluster.html

下面列出了可用于弹性缓存的属性列表。

"AutoMinorVersionUpgrade"    : Boolean,
"AZMode"                     : String,
"CacheNodeType"              : String,
"CacheParameterGroupName"    : String,
"CacheSecurityGroupNames"    : [ String, ... ],
"CacheSubnetGroupName"       : String,
"ClusterName"                : String,
"Engine"                     : String,
"EngineVersion"              : String,
"NotificationTopicArn"       : String,
"Port"                       : Integer,
"PreferredAvailabilityZone"  : String,
"PreferredAvailabilityZones" : [String, ... ],
"PreferredMaintenanceWindow" : String,
"SnapshotArns"               : [String, ... ],
"SnapshotName"               : String,
"SnapshotRetentionLimit"     : Integer,
"SnapshotWindow"             : String,
"Tags"                       : [Resource Tag, ...],
"VpcSecurityGroupIds"        : [String, ...]

这是您可以设置 Redis 以编程方式使用多可用区的两种方法。

使用 CLI

aws elasticache modify-replication-group \
    --replication-group-id myReplGroup \
    --automatic-failover-enabled 

使用 Elasticache API

https://elasticache.us-west-2.amazonaws.com/
    ?Action=ModifyReplicationGroup
    &AutoFailover=true
    &ReplicationGroupId=myReplGroup
    &Version=2015-02-02
    &SignatureVersion=4
    &SignatureMethod=HmacSHA256
    &Timestamp=20140401T192317Z
    &X-Amz-Credential=<credential>

这是您在为 Redis 选择 Multi Az 时应该阅读的一些注意事项。

http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/AutoFailover.html#AutoFailover.Notes

下面是云形成的属性:

{
  "Type" : "AWS::ElastiCache::ReplicationGroup",
  "Properties" : {
    "AutomaticFailoverEnabled" : Boolean,
    "AutoMinorVersionUpgrade" : Boolean,
    "CacheNodeType" : String,
    "CacheParameterGroupName" : String,
    "CacheSecurityGroupNames" : [ String, ... ],
    "CacheSubnetGroupName" : String,
    "Engine" : String,
    "EngineVersion" : String,
    "NotificationTopicArn" : String,
    "NumCacheClusters" : Integer,
    "Port" : Integer,
    "PreferredCacheClusterAZs" : [ String, ... ],
    "PreferredMaintenanceWindow" : String,
    "ReplicationGroupDescription" : String,
    "SecurityGroupIds" : [ String, ... ],
    "SnapshotArns" : [ String, ... ],
    "SnapshotRetentionLimit" : Integer,
    "SnapshotWindow" : String
  }
}

您必须针对 Multi Az

调整此 属性

AutomaticFailoverEnabled

表示是否启用多可用区。启用多可用区后,如果现有主集群发生故障,只读副本将自动提升为读写主集群。如果指定 true,则必须为 NumCacheNodes 属性 指定一个大于 1 的值。默认情况下,AWS CloudFormation 将该值设置为 true。

有关多可用区的更多信息,请参阅 Amazon ElastiCache 用户指南中的 Multi-AZ with Redis Replication Groups

备注 您不能为 2.8.6 之前的 Redis 版本或 T1 和 T2 缓存节点类型启用自动故障转移。 必填:否

类型:布尔值

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html