ALIYUN::REDIS::Instance類型用於建立Redis。
文法
{
"Type": "ALIYUN::REDIS::Instance",
"Properties": {
"VpcId": String,
"EvictionPolicy": String,
"BackupPolicy": Map,
"ZoneId": String,
"InstanceClass": String,
"InstanceMaintainTime": Map,
"Tags": List,
"VpcPasswordFree": Boolean,
"VSwitchId": String,
"SecurityGroupId": String,
"EngineVersion": String,
"SSLEnabled": String,
"Password": String,
"InstanceName": String,
"DeletionForce": Boolean,
"Connections": Map,
"ChargeType": String,
"Period": Integer,
"AutoRenewDuration": Integer,
"ProductType": String,
"SubscriptionDeletionForce": Boolean,
"SecondaryZoneId": String,
"ResourceGroupId": String,
"PeriodUnit": String,
"TairConfig": Map,
"ShardCount": Integer,
"NodeType": String,
"DeletionProtection": Boolean,
"ReadOnlyCount": Integer
}
}屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
EngineVersion | String | 否 | 是 | 資料庫版本。 | 取值:
|
InstanceClass | String | 否 | 是 | 執行個體規格。 | 更多資訊,請參見執行個體規格導航與常見問題。 |
InstanceMaintainTime | Map | 否 | 是 | 執行個體的可維護時間段。 | 無 |
Tags | List | 否 | 是 | 標籤。 | 每個執行個體最多可以綁定20個標籤。 更多資訊,請參見Tags屬性。 |
VpcPasswordFree | Boolean | 否 | 否 | 是否啟用免密碼訪問專用網路中的執行個體。 | 取值:
|
VpcId | String | 否 | 否 | 專用網路ID。 | 無 |
EvictionPolicy | String | 否 | 否 | 資料逐出策略。 | 取值:
|
ZoneId | String | 否 | 否 | 可用性區域ID。 | 當建立的執行個體屬於專用網路時,該參數必須指定。 建立多可用性區域執行個體時,您可以調用DescribeZones - 查詢支援的可用性區域介面查詢支援的多可用性區域ID。 |
VSwitchId | String | 否 | 否 | 專用網路下的交換器ID。 | 無 |
SecurityGroupId | String | 否 | 是 | 安全性群組ID。 | 最多支援設定10個ID,ID之間用半形逗號(,)分隔。 |
Password | String | 否 | 是 | 密碼。 | 長度為8~30個字元,必須同時包含大寫英文字母、小寫英文字母和數字。 |
SSLEnabled | String | 否 | 是 | SSL狀態。 | 取值:
|
InstanceName | String | 否 | 是 | 執行個體名稱。 | 長度為2~128個字元。必須以英文字母或漢字開頭,可包含英文字母、數字、漢字、底線(_)、短劃線(-)和半形句號(.)。 |
DeletionForce | Boolean | 否 | 是 | 是否在回收時刪除執行個體。 | 取值:
|
SubscriptionDeletionForce | Boolean | 否 | 否 | 該選項僅適用於訂用帳戶執行個體。對於訂用帳戶執行個體,如果此選項為 true,則在刪除之前會將執行個體轉換為隨用隨付執行個體;如果為 false,則不會執行強制移除。此操作會產生額外費用,請謹慎選擇。 | 無 |
Connections | Map | 否 | 是 | 串連地址。 | 更多資訊,請參見Connections屬性。 |
BackupPolicy | Map | 否 | 是 | 備份策略。 | 更多資訊,請參見BackupPolicy屬性。 |
ChargeType | String | 否 | 是 | 執行個體付費類型。 | 取值:
|
Period | Integer | 否 | 是 | 付費周期。 | 取值:1~9、12、24、36、60。 單位:月。 |
AutoRenewDuration | Integer | 否 | 是 | 自動續約時間長度。 | 取值範圍:1~12。 單位:月。 當執行個體即將到期時,將根據該參數指定的時間長度自動續約。 說明 當ChargeType取值為 PrePaid時該參數有效。 |
ProductType | String | 否 | 否 | 產品類型。 | 取值:
說明 建議設定 ProductType 屬性,能加快參數查詢的速度。 |
SecondaryZoneId | String | 否 | 是 | 備可用性區域ID。 | 可調用DescribeZones - 查詢支援的可用性區域介面查詢。 說明 傳入本參數可以實現主備資料節點分布在不同的可用性區域,實現跨可用性區域容災,能夠承受機房層級的故障。 |
ResourceGroupId | String | 否 | 是 | 資源群組ID。 | 無 |
PeriodUnit | String | 否 | 是 | 時間長度單位。 | 取值:
|
TairConfig | Map | 否 | 否 | Tair配置。 | 更多資訊,請參見TairConfig屬性。 |
ReadOnlyCount | Integer | 否 | 否 | 主可用性區域的唯讀節點數。 | 說明 ReadOnlyCount 參數僅適用於雲原生版、開啟讀寫分離的執行個體。如果執行個體為叢集架構,則上述參數分別表示單分區的(主、備可用性區域)唯讀節點數量。 |
ShardCount | Integer | 否 | 否 | 分區數。 | 本參數僅適用於建立雲端硬碟版叢集架構執行個體,您可以通過該參數實現自訂分區數量。 |
NodeType | String | 否 | 否 | 節點類型。 | 取值:
說明 雲原生版執行個體請選擇MASTER_SLAVE或STAND_ALONE,經典版執行個體請選擇double或single。 |
DeletionProtection | Boolean | 否 | 是 | 是否已開啟釋放保護功能。 | 取值:
|
BackupPolicy文法
"BackupPolicy": {
"PreferredBackupPeriod": "String",
"PreferredBackupTime": "String",
"EnableBackupLog": "Integer"
}BackupPolicy屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
PreferredBackupPeriod | String | 是 | 是 | 備份周期。 | 取值:
|
PreferredBackupTime | String | 是 | 是 | 備份時間。 | 格式: |
EnableBackupLog | Integer | 否 | 是 | 開啟或關閉增量備份。 | 取值:
|
InstanceMaintainTime文法
"InstanceMaintainTime": {
"MaintainStartTime": "String",
"MaintainEndTime": "String"
}InstanceMaintainTime屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
MaintainStartTime | String | 否 | 否 | 可維護時間段的開始時間。 | 格式: |
MaintainEndTime | String | 否 | 否 | 可維護時間段的結束時間。 | 格式: 說明 開始時間和結束時間的間隔應為1小時,例如:MaintainStartTime為 |
Tags文法
"Tags": [
{
"Key": String,
"Value": String
}
] Tags屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Key | String | 是 | 否 | 標籤鍵。 | 同帳號同地區下標籤鍵唯一。 |
Value | String | 否 | 否 | 標籤值。 | 無 |
Connections文法
"Connections": {
"VpcPrivateConnection": "Map",
"ClassicInnerConnection": "Map",
"DirectConnection": "Map",
"PublicConnection": "Map"
}Connections屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
VpcPrivateConnection | Map | 否 | 是 | VPC內網地址。 | 更多資訊,請參見VpcPrivateConnection屬性。 |
ClassicInnerConnection | Map | 否 | 是 | 經典內網地址。 | 更多資訊,請參見ClassicInnerConnection屬性。 |
DirectConnection | Map | 否 | 是 | 直接連接地址。該執行個體是一個叢集執行個體。您可以根據需要申請直接連接端點。 | 更多資訊,請參見DirectConnection屬性。 |
PublicConnection | Map | 否 | 是 | 公用地址。 | 更多資訊,請參見PublicConnection屬性。 |
VpcPrivateConnection文法
"VpcPrivateConnection": {
"ConnectionPort": Integer,
"ConnectionString": String
}VpcPrivateConnection屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ConnectionPort | Integer | 是 | 是 | 執行個體的ApsaraDB服務連接埠號碼。 | 取值範圍:1024~65535。 |
ConnectionString | String | 是 | 是 | 公用端點的首碼。 | 長度為8~64個字元,必須以小寫英文字母開頭。可包含小寫英文字母和數字。 |
PublicConnection文法
"PublicConnection": {
"ConnectionPort": Integer,
"ConnectionString": String
}PublicConnection屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ConnectionPort | Integer | 是 | 是 | 執行個體的ApsaraDB服務連接埠號碼。 | 取值範圍:1024~65535。 |
ConnectionString | String | 是 | 是 | 公用端點的首碼。 | 長度為8~64個字元,必須以小寫英文字母開頭。可包含小寫英文字母和數字。 |
DirectConnection文法
"DirectConnection": {
"ConnectionPort": Integer,
"ConnectionString": String
}DirectConnection屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ConnectionPort | Integer | 是 | 是 | 執行個體的ApsaraDB服務連接埠號碼。 | 取值範圍:1024~65535。 |
ConnectionString | String | 是 | 是 | 公用端點的首碼。 | 長度為8~64個字元,必須以小寫英文字母開頭。可包含小寫英文字母和數字。 |
ClassicInnerConnection文法
"ClassicInnerConnection": {
"ConnectionPort": Integer,
"ConnectionString": String
}ClassicInnerConnection屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ConnectionPort | Integer | 是 | 是 | 執行個體的ApsaraDB服務連接埠號碼。 | 取值範圍:1024~65535。 |
ConnectionString | String | 是 | 是 | 公用端點的首碼。 | 長度為8~64個字元,必須以小寫英文字母開頭。可包含小寫英文字母和數字。 |
TairConfig文法
"TairConfig": {
"Storage": "Integer",
"StorageType": "String",
"ShardCount": "Integer"
}TairConfig屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Storage | Integer | 否 | 否 | 雲端硬碟的儲存空間。 | 不同的規格取值範圍有所區別。更多資訊,請參見磁碟型執行個體規格。 |
StorageType | String | 否 | 否 | 儲存類型。 | 取值:
|
ShardCount | Integer | 否 | 否 | 執行個體中的資料節點個數。 | 取值:
|
傳回值
Fn::GetAtt
InstanceId:執行個體ID。
OrderId:執行個體訂單ID。
ConnectionDomain:執行個體的私網串連地址。
Port:Redis服務連接埠。
InstanceName:執行個體名稱。
InstanceClass:執行個體規格。
VpcId:專用網路ID。
Capacity:執行個體的儲存容量。
InstanceType:執行個體的引擎版本。
ChargeType:執行個體的計費方式。
PackageType:計劃類型。
Connections:執行個體支援的最大串連數。
ArchitectureType:架構類型。
NodeType:節點類型。
HasRenewChangeOrder:阿里雲帳號是否有待續訂或擴容訂單。
ResourceGroupId:資源群組ID。
QPS:每秒訪問次數,取值為當前規格執行個體的理論值。
ZoneId:執行個體所屬的可用性區域ID。
Bandwidth:執行個體頻寬。單位:Mbps。
EngineVersion:版本類型。
NetworkType:網路類型。
VSwitchId:交換器ID。
PrivateIp:執行個體的私網IP地址。
PublicConnectionString:執行個體的公用連接字串。
VpcPrivateConnectionPort:VPC私人串連連接埠。
ClassicInnerConnectionString:執行個體的經典內部連接字串。
VpcPrivateConnectionString:執行個體的VPC私人連接字串。
PublicConnectionPort:執行個體的公用串連連接埠。
DirectConnectionString:執行個體的直接連接字串。
DirectConnectionPort:執行個體的直接連接連接埠。
ClassicInnerConnectionPort:執行個體的經典內串連連接埠。
樣本
情境 1 :建立Redis。
ROSTemplateFormatVersion: '2015-09-01'
Description: {}
Parameters:
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
ZoneId:
Type: String
Description:
zh-cn: 建立執行個體前,請確認可用性區域是否支援Redis資源的規格。
en: Before you create an instance, confirm that the Availability Zone supports the specifications of Redis resources.
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
Label:
en: Zone ID
zh-cn: 可用性區域
VSwitchId:
Type: String
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: ${VpcId}
ZoneId: ${ZoneId}
Resources:
RedisInstance:
Type: ALIYUN::REDIS::Instance
Properties:
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
InstanceClass: redis.master.small.default
EvictionPolicy: noeviction
ZoneId:
Ref: ZoneId
InstanceName: DefaultRedis
Password: Admin@123!
Outputs:
InstanceId:
Value:
Fn::GetAtt:
- RedisInstance
- InstanceId {
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
},
"Parameters": {
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"ZoneId": {
"Type": "String",
"Description": {
"zh-cn": "建立執行個體前,請確認可用性區域是否支援Redis資源的規格。",
"en": "Before you create an instance, confirm that the Availability Zone supports the specifications of Redis resources."
},
"AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
"Label": {
"en": "Zone ID",
"zh-cn": "可用性區域"
}
},
"VSwitchId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"VpcId": "${VpcId}",
"ZoneId": "${ZoneId}"
}
}
},
"Resources": {
"RedisInstance": {
"Type": "ALIYUN::REDIS::Instance",
"Properties": {
"VpcId": {
"Ref": "VpcId"
},
"VSwitchId": {
"Ref": "VSwitchId"
},
"InstanceClass": "redis.master.small.default",
"EvictionPolicy": "noeviction",
"ZoneId": {
"Ref": "ZoneId"
},
"InstanceName": "DefaultRedis",
"Password": "Admin@123!"
}
}
},
"Outputs": {
"InstanceId": {
"Value": {
"Fn::GetAtt": [
"RedisInstance",
"InstanceId"
]
}
}
}
}情境 2 :建立Redis,並添加 IP白名單。
ROSTemplateFormatVersion: '2015-09-01'
Description: {}
Parameters:
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
ZoneId:
Type: String
Description:
zh-cn: 建立執行個體前,請確認可用性區域是否支援Redis資源的規格。
en: Before you create an instance, confirm that the Availability Zone supports the specifications of Redis resources.
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
Label:
en: Zone ID
zh-cn: 可用性區域
VSwitchId:
Type: String
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: ${VpcId}
ZoneId: ${ZoneId}
Resources:
RedisInstance:
Type: ALIYUN::REDIS::Instance
Properties:
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
InstanceClass: redis.master.small.default
EvictionPolicy: noeviction
ZoneId:
Ref: ZoneId
InstanceName: DefaultRedis
Password: Admin@123!
REDISWhitelist:
Type: ALIYUN::REDIS::Whitelist
Properties:
InstanceId:
Ref: RedisInstance
SecurityIps: 192.168.0.0/16
Outputs:
InstanceId:
Value:
Fn::GetAtt:
- RedisInstance
- InstanceId {
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {},
"Parameters": {
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"ZoneId": {
"Type": "String",
"Description": {
"zh-cn": "建立執行個體前,請確認可用性區域是否支援Redis資源的規格。",
"en": "Before you create an instance, confirm that the Availability Zone supports the specifications of Redis resources."
},
"AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
"Label": {
"en": "Zone ID",
"zh-cn": "可用性區域"
}
},
"VSwitchId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"VpcId": "${VpcId}",
"ZoneId": "${ZoneId}"
}
}
},
"Resources": {
"RedisInstance": {
"Type": "ALIYUN::REDIS::Instance",
"Properties": {
"VpcId": {
"Ref": "VpcId"
},
"VSwitchId": {
"Ref": "VSwitchId"
},
"InstanceClass": "redis.master.small.default",
"EvictionPolicy": "noeviction",
"ZoneId": {
"Ref": "ZoneId"
},
"InstanceName": "DefaultRedis",
"Password": "Admin@123!"
}
},
"REDISWhitelist": {
"Type": "ALIYUN::REDIS::Whitelist",
"Properties": {
"InstanceId": {
"Ref": "RedisInstance"
},
"SecurityIps": "192.168.0.0/16"
}
}
},
"Outputs": {
"InstanceId": {
"Value": {
"Fn::GetAtt": [
"RedisInstance",
"InstanceId"
]
}
}
}
}情境 3 :通過DTS實現MySQL與Redis的緩衝同步。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 該模板通過DTS實現MySQL與Redis的緩衝同步,包括VPC、ECS、RDS、Redis執行個體建立及安全配置,同時設定消費組確保資料一致性。
en: This template achieves cache synchronization between MySQL and Redis via DTS,
encompassing the creation and security configuration of VPC, ECS, RDS, and Redis
instances, alongside the establishment of consumer groups to ensure data consistency.
Parameters:
ZoneId:
Type: String
Label:
en: VSwitch Availability Zone
zh-cn: 交換器可用性區域
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
RDSDBUser:
Type: String
Label:
en: RDS DB Username
zh-cn: RDS資料庫帳號
Description:
en: Username of database.
zh-cn: RDS資料庫帳號。
ConstraintDescription:
en: Consist of 2 to 16 characters of lowercase letters, underline. Must begin
with a letter and be end with an alphanumeric character.
zh-cn: 由 2 到 16 個小寫字母組成,底線。必須以字母開頭,以字母數字字元結尾。
Default: demouser123
MinLength: 2
MaxLength: 16
DbName:
Type: String
Label:
en: RDS DB Name
zh-cn: RDS資料庫名稱
ConstraintDescription:
en: Consist of 2 to 16 characters of lowercase letters, underline. Must begin with a letter and be end with an alphanumeric character.
zh-cn: 由 2 到 16 個小寫字母組成,底線。必須以字母開頭,以字母數字字元結尾。
Default: demodb
Required: true
MinLength: 2
MaxLength: 16
RDSDBPassword:
Type: String
Label:
en: RDS DB Password
zh-cn: RDS資料庫密碼
Description:
en: RDS database password, consisting of letters, numbers, and underline(_),
is 8 to 32 characters long,Must contain three different types of characters.
zh-cn: RDS資料庫密碼,由字母、數字、底線(_)組成,長度為8~32個字元,必須包含3種不同類型的字元。
ConstraintDescription:
en: Consisting of letters, numbers, and underline(_),
is 8 to 32 characters long.
zh-cn: 由字母、數字、底線(_)組成,長度為8~32個字元。
AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
MinLength: 8
MaxLength: 32
NoEcho: true
DBInstanceClass:
Type: String
Label:
en: Instance Class
zh-cn: 執行個體規格
AssociationProperty: ALIYUN::RDS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
EngineVersion: "8.0"
Engine: MySQL
Category: HighAvailability
DBInstanceStorageType: cloud_essd
CommodityCode: bards
Default: mysql.x4.medium.2c
DtsJobName:
Type: String
Label:
en: Dts Job Name
zh-cn: 同步任務名稱
Description:
en: You are advised to configure a name with service significance (without unique requirement) for easy identification.
zh-cn: 建議配置具有業務意義的名稱(無唯一性要求),便於後續識別。
Default: mysql2redis_dts
RedisInstanceClass:
Type: String
Label:
en: Tair Specifications
zh-cn: Tair 規格
Description:
en: <font color='blue'><b>Before selecting a model, please confirm whether the model is in stock in the current availability zone. To save testing costs, it is recommended to use a model with 2G memory, for example:tair.rdb.2g</b></font>, see detail:<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><b><font color='red'>Specification inquiry</font></b></a>.
zh-cn: <font color='blue'><b>選擇機型前請先確認當前可用性區域下該機型是否有庫存,為節省測試成本,推薦使用2GB的規格,例如:tair.rdb.2g</b></font>,<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><b><font color='red'>規格查詢</font></b></a>。
AssociationProperty: ALIYUN::REDIS::Instance::InstanceClass
AssociationPropertyMetadata:
Engine: Redis
ProductType: Tair_rdb
InstanceChargeType: PostPaid
ZoneId: ${ZoneId1}
OrderType: BUY
Default: tair.rdb.2g
RedisPassword:
Type: String
Label:
en: Instance Password
zh-cn: 執行個體密碼
Description:
en: 'Length 8-32 characters, can contain size letters, Numbers and special symbols,
including:! @ # $ % ^ & * ( ) _ + - ='
zh-cn: 長度8-32個字元,可包含大小字母、數字及特殊符號(包含:!@#$%^&*()_+-=)
ConstraintDescription:
en: '8-32 characters, can contain size letters, Numbers and special symbols,
including:! @ # $ % ^ & * ( ) _ + - ='
zh-cn: 8-32個字元,可包含大小字母、數字及特殊符號(包含:!@#$%^&*()_+-=)
MinLength: '8'
MaxLength: '32'
NoEcho: true
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchName:
Fn::Join:
- '-'
- - VSwitch
- StackId
- Ref: ALIYUN::StackId
CidrBlock: 192.168.0.0/24
RdsDBInstance:
Type: ALIYUN::RDS::DBInstance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
DBInstanceClass:
Ref: DBInstanceClass
DBInstanceStorage: 100
Engine: MySQL
EngineVersion: "8.0"
MasterUserPassword:
Ref: RDSDBPassword
MasterUserType: Super
MasterUsername:
Ref: RDSDBUser
DBMappings:
- CharacterSetName: utf8mb4
DBName:
Ref: DbName
Category: HighAvailability
DBInstanceStorageType: cloud_essd
SecurityIPList: 192.168.0.0/16
SlaveZoneIds:
- Ref: ZoneId
RedisInstance:
Type: ALIYUN::REDIS::Instance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
InstanceClass:
Ref: RedisInstanceClass
InstanceName: rds_mysql2redis_redis
EvictionPolicy: noeviction
EngineVersion: '6.0'
Password:
Ref: RedisPassword
Whitelist:
Type: ALIYUN::REDIS::Whitelist
Properties:
InstanceId:
Ref: RedisInstance
SecurityIps: 192.168.0.0/16
MigrationJob:
Type: ALIYUN::DTS::SynchronizationJob2
Properties:
DtsJobName:
Ref: DtsJobName
SourceEndpoint:
InstanceType: RDS
InstanceID:
Ref: RdsDBInstance
EngineName: MYSQL
Region:
Ref: ALIYUN::Region
UserName:
Ref: RDSDBUser
Password:
Ref: RDSDBPassword
DestinationEndpoint:
InstanceType: Redis
InstanceID:
Ref: RedisInstance
EngineName: Redis
Region:
Ref: ALIYUN::Region
Password:
Ref: RedisPassword
StructureInitialization: false
DelayNotice: true
ErrorNotice: true
DelayRuleTime: 60
DataInitialization: true
DataSynchronization: true
DbList:
Fn::GetJsonValue:
- DbList
- Fn::Sub: '{ "DbList": { "${DbName}": { "name": "0", "all": true, "customAttachedColumn": { "__DTS_TP_TO_REDIS_KEY__": { "name": "__DTS_TP_TO_REDIS_KEY__", "syntacticType": "ADD", "value": "__DB__+''.''+__TB__+''.''+pk_str_with_name_value(''.'',''.'')", "type": "STRING", "length": "" }, "__DTS_TP_TO_REDIS_VALUE__": { "name": "__DTS_TP_TO_REDIS_VALUE__", "syntacticType": "ADD", "value": "tp2redis_json_value()", "type": "STRING", "length": "" } } }}}'
DtsInstance:
Type: ALIYUN::DTS::Instance
Properties:
JobId:
Fn::GetAtt:
- MigrationJob
- DtsJobId
InstanceClass: small
PayType: PostPaid
AutoStart: true
Type: SYNC
SourceRegion:
Ref: ALIYUN::Region
DestinationRegion:
Ref: ALIYUN::Region
SourceEndpointEngineName: MySQL
DestinationEndpointEngineName: Redis
Outputs:
RdsInstanceAddress:
Description:
en: RDS Instance Address.
zh-cn: RDS執行個體地址。
Value:
'Fn::Sub':
- 'https://rds.console.alibabacloud.com/detail/${InstanceID}/basicInfo?region=${Region}'
- InstanceID:
Ref: RdsDBInstance
Region:
Ref: ALIYUN::Region
TairInstanceAddress:
Description:
en: Tair Instance Address.
zh-cn: Tair執行個體地址。
Value:
'Fn::Sub':
- 'https://kvstore.console.alibabacloud.com/Redis/instance/${Region}/${InstanceID}'
- InstanceID:
Ref: RedisInstance
Region:
Ref: ALIYUN::Region
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId
Label:
default:
en: Infrastructure Configuration
zh-cn: 基礎資源配置(必填)
- Parameters:
- DBInstanceClass
- DbName
- RDSDBUser
- RDSDBPassword
Label:
default: RDS
- Parameters:
- RedisInstanceClass
- RedisPassword
Label:
default: Tair
- Parameters:
- DtsJobName
Label:
default: DTS
TemplateTags:
- acs:technical-solution:database:即時同步RDS與Redis構建緩衝一致性-tech_solu_21
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "該模板通過DTS實現MySQL與Redis的緩衝同步,包括VPC、ECS、RDS、Redis執行個體建立及安全配置,同時設定消費組確保資料一致性。",
"en": "This template achieves cache synchronization between MySQL and Redis via DTS, encompassing the creation and security configuration of VPC, ECS, RDS, and Redis instances, alongside the establishment of consumer groups to ensure data consistency."
},
"Parameters": {
"ZoneId": {
"Type": "String",
"Label": {
"en": "VSwitch Availability Zone",
"zh-cn": "交換器可用性區域"
},
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
},
"RDSDBUser": {
"Type": "String",
"Label": {
"en": "RDS DB Username",
"zh-cn": "RDS資料庫帳號"
},
"Description": {
"en": "Username of database.",
"zh-cn": "RDS資料庫帳號。"
},
"ConstraintDescription": {
"en": "Consist of 2 to 16 characters of lowercase letters, underline. Must begin with a letter and be end with an alphanumeric character.",
"zh-cn": "由 2 到 16 個小寫字母組成,底線。必須以字母開頭,以字母數字字元結尾。"
},
"Default": "demouser123",
"MinLength": 2,
"MaxLength": 16
},
"DbName": {
"Type": "String",
"Label": {
"en": "RDS DB Name",
"zh-cn": "RDS資料庫名稱"
},
"ConstraintDescription": {
"en": "Consist of 2 to 16 characters of lowercase letters, underline. Must begin with a letter and be end with an alphanumeric character.",
"zh-cn": "由 2 到 16 個小寫字母組成,底線。必須以字母開頭,以字母數字字元結尾。"
},
"Default": "demodb",
"Required": true,
"MinLength": 2,
"MaxLength": 16
},
"RDSDBPassword": {
"Type": "String",
"Label": {
"en": "RDS DB Password",
"zh-cn": "RDS資料庫密碼"
},
"Description": {
"en": "RDS database password, consisting of letters, numbers, and underline(_), is 8 to 32 characters long,Must contain three different types of characters.",
"zh-cn": "RDS資料庫密碼,由字母、數字、底線(_)組成,長度為8~32個字元,必須包含3種不同類型的字元。"
},
"ConstraintDescription": {
"en": "Consisting of letters, numbers, and underline(_), is 8 to 32 characters long.",
"zh-cn": "由字母、數字、底線(_)組成,長度為8~32個字元。"
},
"AssociationProperty": "ALIYUN::RDS::Instance::AccountPassword",
"MinLength": 8,
"MaxLength": 32,
"NoEcho": true
},
"DBInstanceClass": {
"Type": "String",
"Label": {
"en": "Instance Class",
"zh-cn": "執行個體規格"
},
"AssociationProperty": "ALIYUN::RDS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"ZoneId": "${ZoneId}",
"EngineVersion": "8.0",
"Engine": "MySQL",
"Category": "HighAvailability",
"DBInstanceStorageType": "cloud_essd",
"CommodityCode": "bards"
},
"Default": "mysql.x4.medium.2c"
},
"DtsJobName": {
"Type": "String",
"Label": {
"en": "Dts Job Name",
"zh-cn": "同步任務名稱"
},
"Description": {
"en": "You are advised to configure a name with service significance (without unique requirement) for easy identification.",
"zh-cn": "建議配置具有業務意義的名稱(無唯一性要求),便於後續識別。"
},
"Default": "mysql2redis_dts"
},
"RedisInstanceClass": {
"Type": "String",
"Label": {
"en": "Tair Specifications",
"zh-cn": "Tair 規格"
},
"Description": {
"en": "<font color='blue'><b>Before selecting a model, please confirm whether the model is in stock in the current availability zone. To save testing costs, it is recommended to use a model with 2G memory, for example:tair.rdb.2g</b></font>, see detail:<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><b><font color='red'>Specification inquiry</font></b></a>.",
"zh-cn": "<font color='blue'><b>選擇機型前請先確認當前可用性區域下該機型是否有庫存,為節省測試成本,推薦使用2GB的規格,例如:tair.rdb.2g</b></font>,<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><b><font color='red'>規格查詢</font></b></a>。"
},
"AssociationProperty": "ALIYUN::REDIS::Instance::InstanceClass",
"AssociationPropertyMetadata": {
"Engine": "Redis",
"ProductType": "Tair_rdb",
"InstanceChargeType": "PostPaid",
"ZoneId": "${ZoneId1}",
"OrderType": "BUY"
},
"Default": "tair.rdb.2g"
},
"RedisPassword": {
"Type": "String",
"Label": {
"en": "Instance Password",
"zh-cn": "執行個體密碼"
},
"Description": {
"en": "Length 8-32 characters, can contain size letters, Numbers and special symbols, including:! @ # $ % ^ & * ( ) _ + - =",
"zh-cn": "長度8-32個字元,可包含大小字母、數字及特殊符號(包含:!@#$%^&*()_+-=)"
},
"ConstraintDescription": {
"en": "8-32 characters, can contain size letters, Numbers and special symbols, including:! @ # $ % ^ & * ( ) _ + - =",
"zh-cn": "8-32個字元,可包含大小字母、數字及特殊符號(包含:!@#$%^&*()_+-=)"
},
"MinLength": "8",
"MaxLength": "32",
"NoEcho": true
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16"
}
},
"VSwitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"ZoneId": {
"Ref": "ZoneId"
},
"VpcId": {
"Ref": "Vpc"
},
"VSwitchName": {
"Fn::Join": [
"-",
[
"VSwitch",
"StackId",
{
"Ref": "ALIYUN::StackId"
}
]
]
},
"CidrBlock": "192.168.0.0/24"
}
},
"RdsDBInstance": {
"Type": "ALIYUN::RDS::DBInstance",
"Properties": {
"ZoneId": {
"Ref": "ZoneId"
},
"VpcId": {
"Ref": "Vpc"
},
"VSwitchId": {
"Ref": "VSwitch"
},
"DBInstanceClass": {
"Ref": "DBInstanceClass"
},
"DBInstanceStorage": 100,
"Engine": "MySQL",
"EngineVersion": "8.0",
"MasterUserPassword": {
"Ref": "RDSDBPassword"
},
"MasterUserType": "Super",
"MasterUsername": {
"Ref": "RDSDBUser"
},
"DBMappings": [
{
"CharacterSetName": "utf8mb4",
"DBName": {
"Ref": "DbName"
}
}
],
"Category": "HighAvailability",
"DBInstanceStorageType": "cloud_essd",
"SecurityIPList": "192.168.0.0/16",
"SlaveZoneIds": [
{
"Ref": "ZoneId"
}
]
}
},
"RedisInstance": {
"Type": "ALIYUN::REDIS::Instance",
"Properties": {
"ZoneId": {
"Ref": "ZoneId"
},
"VpcId": {
"Ref": "Vpc"
},
"VSwitchId": {
"Ref": "VSwitch"
},
"InstanceClass": {
"Ref": "RedisInstanceClass"
},
"InstanceName": "rds_mysql2redis_redis",
"EvictionPolicy": "noeviction",
"EngineVersion": "6.0",
"Password": {
"Ref": "RedisPassword"
}
}
},
"Whitelist": {
"Type": "ALIYUN::REDIS::Whitelist",
"Properties": {
"InstanceId": {
"Ref": "RedisInstance"
},
"SecurityIps": "192.168.0.0/16"
}
},
"MigrationJob": {
"Type": "ALIYUN::DTS::SynchronizationJob2",
"Properties": {
"DtsJobName": {
"Ref": "DtsJobName"
},
"SourceEndpoint": {
"InstanceType": "RDS",
"InstanceID": {
"Ref": "RdsDBInstance"
},
"EngineName": "MYSQL",
"Region": {
"Ref": "ALIYUN::Region"
},
"UserName": {
"Ref": "RDSDBUser"
},
"Password": {
"Ref": "RDSDBPassword"
}
},
"DestinationEndpoint": {
"InstanceType": "Redis",
"InstanceID": {
"Ref": "RedisInstance"
},
"EngineName": "Redis",
"Region": {
"Ref": "ALIYUN::Region"
},
"Password": {
"Ref": "RedisPassword"
}
},
"StructureInitialization": false,
"DelayNotice": true,
"ErrorNotice": true,
"DelayRuleTime": 60,
"DataInitialization": true,
"DataSynchronization": true,
"DbList": {
"Fn::GetJsonValue": [
"DbList",
{
"Fn::Sub": "{ \"DbList\": { \"${DbName}\": { \"name\": \"0\", \"all\": true, \"customAttachedColumn\": { \"__DTS_TP_TO_REDIS_KEY__\": { \"name\": \"__DTS_TP_TO_REDIS_KEY__\", \"syntacticType\": \"ADD\", \"value\": \"__DB__+'.'+__TB__+'.'+pk_str_with_name_value('.','.')\", \"type\": \"STRING\", \"length\": \"\" }, \"__DTS_TP_TO_REDIS_VALUE__\": { \"name\": \"__DTS_TP_TO_REDIS_VALUE__\", \"syntacticType\": \"ADD\", \"value\": \"tp2redis_json_value()\", \"type\": \"STRING\", \"length\": \"\" } } }}}"
}
]
}
}
},
"DtsInstance": {
"Type": "ALIYUN::DTS::Instance",
"Properties": {
"JobId": {
"Fn::GetAtt": [
"MigrationJob",
"DtsJobId"
]
},
"InstanceClass": "small",
"PayType": "PostPaid",
"AutoStart": true,
"Type": "SYNC",
"SourceRegion": {
"Ref": "ALIYUN::Region"
},
"DestinationRegion": {
"Ref": "ALIYUN::Region"
},
"SourceEndpointEngineName": "MySQL",
"DestinationEndpointEngineName": "Redis"
}
}
},
"Outputs": {
"RdsInstanceAddress": {
"Description": {
"en": "RDS Instance Address.",
"zh-cn": "RDS執行個體地址。"
},
"Value": {
"Fn::Sub": [
"https://rds.console.alibabacloud.com/detail/${InstanceID}/basicInfo?region=${Region}",
{
"InstanceID": {
"Ref": "RdsDBInstance"
},
"Region": {
"Ref": "ALIYUN::Region"
}
}
]
}
},
"TairInstanceAddress": {
"Description": {
"en": "Tair Instance Address.",
"zh-cn": "Tair執行個體地址。"
},
"Value": {
"Fn::Sub": [
"https://kvstore.console.alibabacloud.com/Redis/instance/${Region}/${InstanceID}",
{
"InstanceID": {
"Ref": "RedisInstance"
},
"Region": {
"Ref": "ALIYUN::Region"
}
}
]
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId"
],
"Label": {
"default": {
"en": "Infrastructure Configuration",
"zh-cn": "基礎資源配置(必填)"
}
}
},
{
"Parameters": [
"DBInstanceClass",
"DbName",
"RDSDBUser",
"RDSDBPassword"
],
"Label": {
"default": "RDS"
}
},
{
"Parameters": [
"RedisInstanceClass",
"RedisPassword"
],
"Label": {
"default": "Tair"
}
},
{
"Parameters": [
"DtsJobName"
],
"Label": {
"default": "DTS"
}
}
],
"TemplateTags": [
"acs:technical-solution:database:即時同步RDS與Redis構建緩衝一致性-tech_solu_21"
]
}
}
}更多樣本,請參考包含此資源的公用模板。