forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tair-restores-data-through-data-flashback.yml
342 lines (342 loc) · 10.7 KB
/
tair-restores-data-through-data-flashback.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
ROSTemplateFormatVersion: '2015-09-01'
Conditions:
IsAccountPasswordEmpty1:
Fn::Equals:
- Ref: AccountPassword
- ''
IsAccountPasswordEmpty2:
Fn::Equals:
- Ref: AccountPassword
- null
WillSetAccountPassword:
Fn::Not:
Fn::Or:
- IsAccountPasswordEmpty1
- IsAccountPasswordEmpty2
Parameters:
InstanceId:
Type: String
Label:
en: Tair Instance ID
zh-cn: Tair实例ID
AssociationProperty: ALIYUN::Redis::Instance::InstanceId
AssociationPropertyMetadata:
EditionType: Enterprise
EcsInstanceId:
Type: String
Label:
en: ECS Instance ID
zh-cn: ECS实例ID
Description:
en: The ECS instance that will access the Tair instance.
zh-cn: 要访问Tair实例的ECS实例。
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AccountPassword:
Type: String
Label:
en: Instance Account Password
zh-cn: 实例账号密码
Description:
en: "If a password has been configured when creating a Tair instance, set this\
\ parameter to reset the password. <br>\nIf no password is configured when\
\ creating a Tair instance, you need to configure a password for the Tair\
\ instance here. <br>\nThe password must be 8 to 32 characters in length.\
\ <br>\nIt must contain at least three of the following character types: uppercase\
\ letters, lowercase letters, digits, and special characters. <br> \nSpecial\
\ characters include <span style=\"background:#E7E9EB;\"><b>!@#$%^&*()_+-=</b></span>."
zh-cn: |-
如果创建Tair实例时已配置密码,设置该参数为重置密码。 <br>
如果创建Tair实例时未配置密码,此处需要为Tair实例配置密码。 <br>
长度为8~32位,需包含大写字母、小写字母、特殊字符和数字中的至少三种,允许的特殊字符包括<span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>。
Default: ''
AllowedPattern: ^(?=.*[a-zA-Z])(?=.*[a-z0-9])(?=.*[a-z!@#$%^&*()_+=-])(?=.*[A-Z0-9])(?=.*[A-Z!@#$%^&*()_+=-])(?=.*[0-9!@#$%^&*()_+=-])[a-zA-Z0-9!@#$%^&*()_+=-]{8,32}$|^$
NoEcho: true
Confirm: true
Resources:
EcsInstanceData:
Type: DATASOURCE::ECS::Instances
Properties:
InstanceIds:
- Ref: EcsInstanceId
WaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
WaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Handle:
Ref: WaitConditionHandle
Timeout: 1230
Count: 1
InstallWebServer:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
- Ref: EcsInstanceId
Type: RunShellScript
Sync: true
Timeout: 1200
CommandContent:
Fn::Sub:
- |-
#!/bin/bash
echo "#########################"
echo "# Install Redis Client"
echo "#########################"
cd ~
if [ -f "redis-${redis_version}/src/redis-cli" ]; then
redis-${redis_version}/src/redis-cli -v
if [ $? -ne 0 ]; then
rm -f redis-${redis_version}.tar.gz
rm -rf redis-${redis_version}
else
${ros_notify} --data-binary "{\"status\": \"SUCCESS\", \"data\": \"`pwd`/redis-${redis_version}/src/redis-cli\"}"
exit 0
fi
fi
ping download.redis.io -w 5 | grep "0 received"
if [ $? -eq 0 ]; then
${ros_notify} --data-binary '{"status": "FAILURE", "reason": "unable to connect to download.redis.io"}'
exit 0
fi
wget https://download.redis.io/releases/redis-${redis_version}.tar.gz
if [ $? -ne 0 ]; then
${ros_notify} --data-binary '{"status": "FAILURE", "reason": "fail to download redis-${redis_version}.tar.gz"}'
exit 0
fi
tar xzf redis-${redis_version}.tar.gz
cd redis-${redis_version}
make
src/redis-cli -v
if [ $? -ne 0 ]; then
${ros_notify} --data-binary '{"status": "FAILURE", "reason": "fail to install redis client"}'
exit 0
fi
${ros_notify} --data-binary "{\"status\": \"SUCCESS\", \"data\": \"`pwd`/src/redis-cli\"}"
- ros_notify:
Fn::GetAtt:
- WaitConditionHandle
- CurlCli
redis_version: 6.0.9
Whitelist:
Type: ALIYUN::REDIS::Whitelist
Properties:
InstanceId:
Ref: InstanceId
SecurityIps:
Fn::Join:
- ','
- Fn::Jq:
- All
- .[] | .PrivateIpAddress[]
- Fn::GetAtt:
- EcsInstanceData
- Instances
SecurityIpGroupName:
Fn::Sub:
- ros_${suffix}
- suffix:
Fn::Select:
- '0'
- Fn::Split:
- '-'
- Ref: ALIYUN::StackId
Template:
Type: ALIYUN::OOS::Template
Properties:
Content: |-
FormatVersion: OOS-2019-06-01
Parameters:
InstanceId:
Type: String
Tasks:
- Name: DescribeBackupPolicy
Action: ACS::ExecuteAPI
Properties:
Service: R-kvstore
API: DescribeBackupPolicy
Parameters:
RegionId: '{{ ACS::RegionId }}'
InstanceId: '{{ InstanceId }}'
Outputs:
PreferredBackupTime:
ValueSelector: .PreferredBackupTime
Type: String
PreferredBackupPeriod:
ValueSelector: .PreferredBackupPeriod
Type: String
EnableBackupLog:
ValueSelector: .EnableBackupLog
Type: Number
- Name: Branch
Action: 'ACS::Choice'
Properties:
DefaultTask: ACS::END
Choices:
- When:
'Fn::Equals':
- 0
- '{{ DescribeBackupPolicy.EnableBackupLog }}'
NextTask: ModifyBackupPolicy
- Name: ModifyBackupPolicy
Action: ACS::ExecuteAPI
Properties:
Service: R-kvstore
API: ModifyBackupPolicy
Parameters:
RegionId: '{{ ACS::RegionId }}'
InstanceId: '{{ InstanceId }}'
PreferredBackupTime: '{{ DescribeBackupPolicy.PreferredBackupTime }}'
PreferredBackupPeriod: '{{ DescribeBackupPolicy.PreferredBackupPeriod }}'
EnableBackupLog: 1
TemplateName:
Fn::Sub: trial-enable-backup-log-${ALIYUN::StackId}
Execution:
Type: ALIYUN::OOS::Execution
Properties:
TemplateName:
Ref: Template
Parameters:
InstanceId:
Ref: InstanceId
ResourceCleaner:
Type: ALIYUN::ROS::ResourceCleaner
Properties:
Action: Scan+CleanUp
Resources:
- ResourceId:
Ref: Execution
ResourceType: OOS:Execution
RegionId:
Ref: ALIYUN::Region
- ResourceId:
Ref: Template
ResourceType: OOS:Template
RegionId:
Ref: ALIYUN::Region
CleanUpTimeout: 120
InstanceData:
Type: DATASOURCE::REDIS::Instances
Properties:
InstanceIds:
Fn::Join:
- ','
- - Ref: InstanceId
TemplateForPassword:
Type: ALIYUN::OOS::Template
Condition: WillSetAccountPassword
Properties:
Content: |-
FormatVersion: OOS-2019-06-01
Parameters:
InstanceId:
Type: String
AccountPassword:
Type: String
Tasks:
- Name: ModifyRedisPassword
Action: ACS::ExecuteAPI
Properties:
Service: R-kvstore
API: ResetAccountPassword
Parameters:
RegionId: '{{ ACS::RegionId }}'
InstanceId: '{{ InstanceId }}'
AccountName: '{{ InstanceId }}'
AccountPassword: '{{ AccountPassword }}'
TemplateName:
Fn::Sub: trial-modify-tair-pwd-${ALIYUN::StackId}
ExecutionForPassword:
Type: ALIYUN::OOS::Execution
Condition: WillSetAccountPassword
Properties:
TemplateName:
Ref: TemplateForPassword
Parameters:
InstanceId:
Ref: InstanceId
AccountPassword:
Ref: AccountPassword
ResourceCleanerForPassword:
Type: ALIYUN::ROS::ResourceCleaner
Condition: WillSetAccountPassword
Properties:
Action: Scan+CleanUp
Resources:
- ResourceId:
Ref: ExecutionForPassword
ResourceType: OOS:Execution
RegionId:
Ref: ALIYUN::Region
- ResourceId:
Ref: TemplateForPassword
ResourceType: OOS:Template
RegionId:
Ref: ALIYUN::Region
CleanUpTimeout: 120
Outputs:
ConsoleURL:
Description:
en: "Console URL for data flashback. \nPlease confirm in the console, after\
\ the \"Start Flashbacking\" button can be clicked, continue to step 5."
zh-cn: |-
数据闪回控制台地址。
请在控制台进行确认,待马上闪回按钮可以单击后,继续步骤五。
Value:
Fn::Sub:
- <a href="https://kvstore.console.aliyun.com/Redis/instance/${ALIYUN::Region}/${InstanceId}/Normal/VPC/${InstanceClass}/backupRestore"
target="_blank">https://kvstore.console.aliyun.com/Redis/instance/${ALIYUN::Region}/${InstanceId}/Normal/VPC/${InstanceClass}/backupRestore</a>
- InstanceClass:
Fn::Jq:
- First
- .[] | .InstanceClass
- Fn::GetAtt:
- InstanceData
- Instances
LoginCLI:
Description:
en: |-
The command line that is used to login Tair.
Please continue to step 5.
zh-cn: |-
登录Tair的命令行。
请继续步骤五。
Value:
Fn::Sub:
- ${redis_cli} -h ${host} -p ${port}
- redis_cli:
Fn::Jq:
- First
- .[]
- Fn::GetAtt:
- WaitCondition
- Data
host:
Fn::Jq:
- First
- .[] | .ConnectionDomain
- Fn::GetAtt:
- InstanceData
- Instances
port:
Fn::Jq:
- First
- .[] | .Port
- Fn::GetAtt:
- InstanceData
- Instances
AccountName:
Description:
en: Instance Account.
zh-cn: 实例账号。
Value:
Ref: InstanceId
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- InstanceId
- EcsInstanceId
- AccountPassword
TemplateTags:
- acs:document:试用教程:Tair通过数据闪回恢复数据