我正在设计一个包含 Redis 服务的模板,我想在 Redis 中启用多可用区功能,以便在主集群发生故障时,只读副本可以提升为主集群。我查看了 CloudFormation 文档,但找不到此功能,即多可用区。它适用于 RDS 服务,但不适用于 Redis。我能否知道如何包含 redis 功能,例如 AWS 负责自动故障转移?
下面列出了可用于弹性缓存的属性列表。
"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 选择多可用区时应阅读的一些注意事项。
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
}
}
您必须针对多可用区调整此属性
自动故障转移已启用
指示是否启用多可用区。启用多可用区后,如果现有主集群发生故障,只读副本会自动提升为读写主集群。如果指定 true,则必须为 NumCacheNodes 属性指定大于 1 的值。默认情况下,AWS CloudFormation 将该值设置为 true。
有关多可用区的更多信息,请参阅 Multi-AZ with Redis Replication Groups在 Amazon ElastiCache 用户指南中。
注意 您无法为早于 2.8.6 的 Redis 版本或 T1 和 T2 缓存节点类型启用自动故障转移。 必填:否
类型: bool 值
关于amazon-web-services - CloudFormation 中的 Redis 多可用区功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38619473/