-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsnapshot-optimize.yml
More file actions
475 lines (450 loc) · 10.8 KB
/
snapshot-optimize.yml
File metadata and controls
475 lines (450 loc) · 10.8 KB
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 搭建基于ECS和ESSD盘的高效率MySQL环境,含安全组、VPC配置,自动快照策略,及克隆实例功能。
en: Establish a high-performance MySQL environment based on ECS instances and ESSD
disks, encompassing Security Group configurations, VPC setups, automated snapshot
policies, and instance cloning functionality.
Parameters:
ecsType:
Default: ecs.g6.large
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
SystemDiskCategory: cloud_essd
InstanceChargeType: PostPaid
ZoneId: '${zoneId}'
Type: String
Label:
zh-cn: ECS 实例规格
en: InstanceType
ecsPassword:
Type: String
Description:
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号)
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
Default: null
MinLength: 8
Label:
zh-cn: 实例密码
en: Instance Password
AllowedPattern: '^[a-zA-Z0-9-\(\)\`\~\!\@\#\$\%\^\&\*\_\-\+\=\|\{\}\[\]\:\;\<\>\,\.\?\/]*$'
MaxLength: 30
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
ConstraintDescription:
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)'
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zoneId:
Default: ''
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
Type: String
Label:
zh-cn: 可用区
en: Availability Zone
Outputs:
EcsLoginAddress:
Description:
zh-cn: Ecs登录地址。
en: ECS Login Address
Value:
'Fn::Sub':
- >-
https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${Region}&instanceId=${InstanceId}
- InstanceId:
Ref: EcsInstance
Region:
Ref: 'ALIYUN::Region'
EcsCloneLoginAddress:
Description:
zh-cn: Ecs(克隆)登录地址。
en: ECS Clone Login Address
Value:
'Fn::Sub':
- >-
https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${Region}&instanceId=${InstanceId}
- InstanceId:
Ref: EcsInstanceClone
Region:
Ref: 'ALIYUN::Region'
EcsInstanceId:
Description: ECS实例ID
Value:
'Fn::GetAtt':
- EcsInstance
- InstanceId
EcsInstanceUser:
Description: ECS实例初始用户
Value: root
EcsInstancePublicIp:
Description: ECS实例公网IP
Value:
'Fn::GetAtt':
- EcsInstance
- PublicIp
MysqlUser:
Description: MySQL初始用户
Value: root
MysqlPassword:
Description: MySQL初始密码
Value: 请登录ECS执行以下命令获取初始密码:sudo grep 'temporary password' /var/log/mysqld.log
SystemDiskId:
Description: 系统盘ID
Value:
'Fn::GetAtt':
- SysTemDisk
- DiskIds
Resources:
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
SecurityGroupIngress:
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 3306/3306
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 22/22
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
VpcId:
Ref: VPC
VPC:
Type: 'ALIYUN::ECS::VPC'
Properties:
VpcName:
'Fn::Join':
- '-'
- - StackId
- Ref: 'ALIYUN::StackId'
CidrBlock: 192.168.0.0/16
VSwitch:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VSwitchName:
Ref: 'ALIYUN::StackName'
VpcId:
Ref: VPC
CidrBlock: 192.168.0.0/24
ZoneId:
Ref: zoneId
EcsInstance:
Type: 'ALIYUN::ECS::Instance'
Properties:
SystemDiskCategory: cloud_essd
VpcId:
Ref: VPC
InternetMaxBandwidthOut: 100
SecurityGroupId:
Ref: SecurityGroup
SystemDiskSize: 40
ImageId: centos_7_9_x64_20G_alibase_
AllocatePublicIP: true
IoOptimized: optimized
InternetChargeType: PayByTraffic
VSwitchId:
Ref: VSwitch
Password:
Ref: ecsPassword
InstanceType:
Ref: ecsType
ZoneId:
Ref: zoneId
InstanceName:
'Fn::Sub': 'ECS_Instance-${ALIYUN::StackId}'
RunCommand:
Type: 'ALIYUN::ECS::RunCommand'
Properties:
Type: RunShellScript
CommandContent:
'Fn::Sub':
- >
#!/bin/sh
cd /tmp/
if wget -N
http://mirrors.cloud.aliyuncs.com/mysql/MySQL-8.0/mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
-O mysql.tar ; then
echo "[INFO] Download mysql rpm bundle.tar successfully."
tar -xf mysql.tar
echo "[INFO] Extract mysql rpm bundle.tar successfully."
if yum install -y mysql-community-{server,client,common,libs,devel}-*; then
echo "[INFO] Install mysql successfully."
else
echo "[ERROR] Failed to install mysql."
exit
fi
else
echo "[ERROR] Failed to download mysql rpm bundle."
echo "[INFO] Install from [dev.mysql.com rpm repository]"
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
if yum -y install mysql-community-server --enablerepo=mysql80-community --nogpgcheck; then
echo "[INFO] Install mysql successfully."
else
echo "[ERROR] Failed to install mysql."
exit
fi
fi
sudo systemctl start mysqld
sudo systemctl enable mysqld
sync
- {}
Sync: true
InstanceIds:
- Ref: EcsInstance
Timeout: 600
DependsOn:
- EcsInstance
SysTemDisk:
Type: 'DATASOURCE::ECS::Disks'
Properties:
InstanceId:
Ref: EcsInstance
DiskType: system
DependsOn:
- RunCommand
SnapshotPolicy:
Type: 'ALIYUN::ECS::AutoSnapshotPolicy'
Properties:
TimePoints:
- 20
- 23
RetentionDays: 1
RepeatWeekdays:
- 1
- 2
DiskIds:
'Fn::GetAtt':
- SysTemDisk
- DiskIds
AutoSnapshotPolicyName:
'Fn::Sub': 'AutoSnapshotPolicy-${ALIYUN::StackId}'
MysqlImage:
Type: 'ALIYUN::ECS::CustomImage'
Properties:
Description: MySQL实例镜像
InstanceId:
Ref: EcsInstance
ImageName:
'Fn::Sub': 'MySQLImage-${ALIYUN::StackId}'
Platform: CentOS
Architecture: x86_64
DependsOn:
- SnapshotPolicy
- RunCommand
EcsInstanceClone:
Type: 'ALIYUN::ECS::Instance'
Properties:
SystemDiskCategory: cloud_essd
VpcId:
Ref: VPC
InternetMaxBandwidthOut: 100
SecurityGroupId:
Ref: SecurityGroup
SystemDiskSize: 40
ImageId:
'Fn::GetAtt':
- MysqlImage
- ImageId
AllocatePublicIP: true
IoOptimized: optimized
InternetChargeType: PayByTraffic
VSwitchId:
Ref: VSwitch
Password:
Ref: ecsPassword
InstanceType:
Ref: ecsType
ZoneId:
Ref: zoneId
InstanceName:
'Fn::Sub': 'ECS_Instance_Clone-${ALIYUN::StackId}'
DependsOn:
- MysqlImage
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- zoneId
- ecsType
- ecsPassword
- ecsImageId
Label:
zh-cn: 基础配置
en: Basic Configuration
TemplateTags:
- 'acs:technical-solution:ebs:EBS部署高性能的MySQL服务-tech_solu_96'
- acs:public_template:Solution:snapshot-optimize
ALIYUN::ROS::Composer:
2d243f5f:
Rect:
- 680
- 540
- 40
- 100
- 1
- 0
ResT: Composer::ROSParameter::AlibabaCloud
034af176:
Parent: 2d243f5f
Rect:
- 640
- 470
- 60
- 150
- 2
- 0
ResT: Composer::ROSParameter::Region
8ee6c8b6:
Res:
- VPC
Parent: 034af176
Rect:
- 480
- 340
- 80
- 260
- 3
- 0
36418f20:
Res:
- RunCommand
Parent: 034af176
Rect:
- 40
- 40
- 640
- 200
- 3
- 0
Hidden: true
9c9f4b38:
Res:
- SysTemDisk
Parent: 034af176
Rect:
- 40
- 40
- 600
- 463
- 3
- 0
ResT: DATASOURCE::ECS::Disks
a2360f0d:
Res:
- SnapshotPolicy
Parent: 034af176
Rect:
- 40
- 40
- 80
- 200
- 3
- 0
Hidden: true
8f23d813:
Res:
- MysqlImage
Parent: 034af176
Rect:
- 40
- 40
- 580
- 200
- 3
- 0
Hidden: true
e0640128:
Res:
- zoneId
Parent: 8ee6c8b6
Rect:
- 440
- 270
- 100
- 310
- 4
- 0
ResT: Composer::ROSParameter::Zone
3956d268:
Res:
- VSwitch
Parent: e0640128
Rect:
- 400
- 200
- 120
- 360
- 5
- 0
67d027f5:
Res:
- SecurityGroup
Parent: 8ee6c8b6
Rect:
- 261
- 146
- 140
- 410
- 10
- 0
49e4a39e:
Parent: 034af176
Edge:
- 36418f20
- 9197b6c5
Line: 0:0:0:gray:0
29f02f86:
Parent: 034af176
Edge:
- 9c9f4b38
- 9197b6c5
Line: 0:0:0:gray:0
9ca29c27:
Parent: 034af176
Edge:
- a2360f0d
- 9c9f4b38
Line: 0:0:0:gray:0
e1f37fa9:
Parent: 034af176
Edge:
- 8f23d813
- 9197b6c5
Line: 0:0:0:gray:0
004b4ef0:
Parent: 034af176
Edge:
- 2099525f
- 8f23d813
Line: 0:0:0:gray:0
9197b6c5:
Res:
- EcsInstance
Parent: 3956d268
Rect:
- 40
- 40
- 288
- 463
- 11
- 0
Layer:
- 67d027f5
2099525f:
Res:
- EcsInstanceClone
Parent: 3956d268
Rect:
- 40
- 40
- 189
- 463
- 11
- 0
Layer:
- 67d027f5