-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmigrate-database-to-cloud.yml
More file actions
583 lines (583 loc) · 16.7 KB
/
migrate-database-to-cloud.yml
File metadata and controls
583 lines (583 loc) · 16.7 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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建ECS与RDS实例,配置安全组与网络,自建MySQL数据库,准备迁移至RDS MySQL 8.0。
en: Create ECS and RDS instances, configure security groups and networking, and prepare for migration to RDS MySQL 8.0.
Parameters:
Zone:
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
Type: String
Description:
zh-cn: 用于创建ECS和RDS的可用区。
en: Availability zone.
Label:
zh-cn: 可用区
en: Availability Zone.
EcsInstanceType:
Type: String
Description:
zh-cn: 自建数据库的ECS实例类型。
en: ECS instance for on-premises database
Label:
zh-cn: ECS实例类型
en: ECS instance type.
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
SystemDiskCategory: cloud_essd
InstanceChargeType: PostPaid
ZoneId: ${Zone}
Default: ecs.e-c1m1.large
InstancePassword:
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号)
Label:
en: ECS Instance Password
zh-cn: ECS 实例密码
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
DBInstanceEngineAndVersion:
Type: String
Description:
zh-cn: 数据库引擎类型及版本,默认为MySQL 8.0
en: 'Database instance engine type and version, default: MySQL 8.0'
Label:
zh-cn: 引擎类型及版本
en: Engine And Version
Default: MySQL 8.0
AllowedValues:
- MySQL 8.0
DBInstanceClass:
Type: String
Description: '在模拟数据迁移体验中,您可以选择最小规格的数据库实例作为迁移目标实例,以减少成本。在生产环境中选择迁移目标实例,需要确保其规格满足您的业务需求。关于RDS实例规格详情,请参考:<a href="https://help.aliyun.com/zh/rds/apsaradb-rds-for-mysql/specifications-2" target="blank">云数据库RDS MySQL产品规格。</a>'
Label:
en: Target RDS Instance Class
zh-cn: 迁移目标RDS实例规格
AssociationProperty: ALIYUN::RDS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId:
Ref: Zone
EngineVersion: '8.0'
DBInstanceStorageType: cloud_essd
Engine: MySQL
Category: Basic
CommodityCode: bards
Default: mysql.n2e.small.1
RDSUserDTSUsername:
Type: String
ConstraintDescription:
en: Consist of 2 to 16 characters, lowercase letters and underscores. Must begin with a letter and end with an alphanumeric character.
zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾
Label:
zh-cn: RDS数据库账号
en: RDS DB Username
Default: dbuser
MaxLength: 16
MinLength: 2
RDSUserDTSPassword:
Type: String
NoEcho: true
Label:
zh-cn: RDS数据库密码
en: RDS database password
AssociationProperty: 'ALIYUN::RDS::Instance::AccountPassword'
WPUserForSQLUsername:
Type: String
ConstraintDescription:
en: Consist of 2 to 16 characters, lowercase letters and underscores. Must begin with a letter and end with an alphanumeric character.
zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾
Label:
zh-cn: ECS 自建 MySQL 数据库账号 (SQL)
en: ECS creates its own MySQL database account (SQL).
Description:
zh-cn: ECS 自建 MySQL 数据库账号,该账号用于数据库 SQL 操作。
en: ECS creates its own MySQL database account, which is used for database SQL operations.
Default: dbuser
MaxLength: 16
MinLength: 2
WPUserForSQLPassword:
Type: String
Label:
zh-cn: ECS 自建 MySQL 数据库密码 (SQL)
en: ECS creates its own MySQL database password (SQL).
AllowedPattern: ^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=]).{8,32}$
NoEcho: true
Description:
en: |-
The password must be 8 to 32 characters in length. <br>
It must contain the following character types: uppercase letters, lowercase letters, digits, and special characters. <br>
Special characters include <span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>.<br>
<b>If you repeatedly provision in this tutorial on the same ECS instance, make sure that the MySQL database password is exactly the same as the password set when the template was executed for the first time. Otherwise, the result of provisioning is unavailable.</b>
zh-cn: |-
长度为8~32位,需包含大写字母、小写字母、特殊字符和数字,允许的特殊字符包括<span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>。
ConstraintDescription:
en: |-
The password must be 8 to 32 characters in length. <br>
It must contain the following character types: uppercase letters, lowercase letters, digits, and special characters. <br>
Special characters include <span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>.<br>
<b>If you repeatedly provision in this tutorial on the same ECS instance, make sure that the MySQL database password is exactly the same as the password set when the template was executed for the first time. Otherwise, the result of provisioning is unavailable.</b>
zh-cn: 长度为8~32位,需包含四项大写字母、小写字母、特殊字符和数字,允许的特殊字符包括<span style="background:#E7E9EB;"><b>!@#$%^&*()_+-=</b></span>。
Resources:
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: RosWaitConditionHandle
Timeout: 3600
RosWaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
CidrBlock: 192.168.0.0/24
ZoneId:
Ref: Zone
VpcId:
Fn::GetAtt:
- Vpc
- VpcId
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VpcName: database-migration-test
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
SecurityGroupName: SG-DTS-GROUP-20220101
VpcId:
Fn::GetAtt:
- Vpc
- VpcId
Database:
Type: ALIYUN::RDS::DBInstance
Properties:
DBInstanceClass:
Ref: DBInstanceClass
ZoneId:
Ref: Zone
DBInstanceDescription: mysqltords
DBInstanceStorage: 20
Category: Basic
DBInstanceStorageType: cloud_essd
VSwitchId:
Ref: VSwitch
Engine: MySQL
VpcId:
Ref: Vpc
SlaveZoneIds:
- Auto
EngineVersion: '8.0'
SecurityIPList:
Fn::GetAtt:
- WebServer
- PrivateIp
MasterUsername:
Ref: RDSUserDTSUsername
MasterUserPassword:
Ref: RDSUserDTSPassword
MasterUserType: Super
SecurityGroupIngress_80:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SourceCidrIp: 0.0.0.0/0
SecurityGroupId:
Ref: SecurityGroup
IpProtocol: tcp
NicType: intranet
PortRange: 80/80
SecurityGroupIngress_3306:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SourceCidrIp: 0.0.0.0/0
SecurityGroupId:
Ref: SecurityGroup
IpProtocol: tcp
NicType: intranet
PortRange: 3306/3306
SecurityGroupIngress_22:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SourceCidrIp: 0.0.0.0/0
SecurityGroupId:
Ref: SecurityGroup
IpProtocol: tcp
NicType: intranet
PortRange: 22/22
WebServer:
Type: ALIYUN::ECS::Instance
Properties:
IoOptimized: optimized
ImageId: aliyun_3_x64_20G_alibase_
SecurityGroupId:
Ref: SecurityGroup
Password:
Ref: InstancePassword
InternetMaxBandwidthOut: 80
VSwitchId:
Ref: VSwitch
VpcId:
Ref: Vpc
InstanceType:
Ref: EcsInstanceType
SystemDiskCategory: cloud_essd
AllocatePublicIP: true
ZoneId:
Ref: Zone
RunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
- Ref: WebServer
Type: RunShellScript
Sync: true
Timeout: 3600
CommandContent:
Fn::Sub: |-
#!/bin/bash
cat << EOF >> ~/.bash_profile
export MYSQL_USER=${WPUserForSQLUsername}
export MYSQL_PWD=${WPUserForSQLPassword}
export ROS_DEPLOY=true
EOF
source ~/.bash_profile
curl -fsSL https://static-aliyun-doc.oss-cn-hangzhou.aliyuncs.com/install-script/mysql-rds/install.sh|sh
${RosWaitConditionHandle.CurlCli} --data-binary '{"status": "SUCCESS"}'
DependsOn:
- SecurityGroupIngress_80
- SecurityGroupIngress_3306
- SecurityGroupIngress_22
DtsInstance:
Type: ALIYUN::DTS::Instance
Properties:
JobId:
Fn::GetAtt:
- MigrationJob
- DtsJobId
InstanceClass: micro
PayType: PostPaid
AutoStart: false
Type: SYNC
SourceRegion:
Ref: ALIYUN::Region
DestinationRegion:
Ref: ALIYUN::Region
SourceEndpointEngineName: MySQL
DestinationEndpointEngineName: MySQL
MigrationJob:
Type: ALIYUN::DTS::SynchronizationJob2
Properties:
DtsJobName: ecs_mysql_2_cloud_dts
SourceEndpoint:
InstanceType: ECS
InstanceID:
Ref: WebServer
EngineName: MYSQL
Port: '3306'
Region:
Ref: ALIYUN::Region
UserName:
Ref: WPUserForSQLUsername
Password:
Ref: WPUserForSQLPassword
DestinationEndpoint:
InstanceType: RDS
InstanceID:
Ref: Database
EngineName: MYSQL
Region:
Ref: ALIYUN::Region
UserName:
Ref: RDSUserDTSUsername
Password:
Ref: RDSUserDTSPassword
StructureInitialization: true
DataInitialization: true
DataSynchronization: true
DataCheckConfigure:
fullCheckRatio: 100
incrementalDataCheck: true
fullCheckValidFailNotice: false
fullCheckReferEndpoint: all
incrementalCheckDelayNotice: false
fullCheckFixData: false
fullCheckModel: 1
fullCheckErrorNotice: false
fullDataCheck: true
fullCheckNoticeValue: 1
incrementalCheckValidFailNotice: false
incrementalCheckErrorNotice: false
dataCheckDbList: '{"dtstestdb":{"name":"dtstestdb","all":true}}'
DbList:
dtstestdb:
name: dtstestdb
all: true
Outputs:
ECSInstanceUsername:
Description:
en: ECS instance login account.
zh-cn: ECS 实例登录账号。
Value: root
ECSInstancePassword:
Description:
en: Login password for the ECS instance.
zh-cn: ECS 实例登录密码。
NoEcho: true
Value:
Ref: InstancePassword
WPUserForSQLUsername:
Description:
en: ECS creates its own MySQL database account, which is used for SQL operations in the database.
zh-cn: ECS 自建 MySQL 数据库账号,该账号用于数据库 SQL 操作。
Value:
Ref: WPUserForSQLUsername
WPUserForSQLPassword:
Description:
en: ECS creates its own MySQL database password, which is used for SQL operations in the database.
zh-cn: ECS 自建 MySQL 数据库账号密码,该账号用于数据库 SQL 操作。
NoEcho: true
Value:
Ref: WPUserForSQLPassword
RDSUserDTSUsername:
Description:
en: High-privilege account for RDS database.
zh-cn: RDS 数据库高权限账号。
Value:
Ref: RDSUserDTSUsername
RDSUserDTSPassword:
Description:
en: High-privilege account password for RDS database.
zh-cn: RDS 数据库高权限账号密码。
NoEcho: true
Value:
Ref: RDSUserDTSPassword
RDSInternalAddress:
Description:
en: The internal network connection address of the RDS instance.
zh-cn: RDS 实例内网连接地址。
Value:
Fn::GetAtt:
- Database
- InnerConnectionString
DTSInstanceAddress:
Description:
en: DTS Sync task address.
zh-cn: DTS同步任务访问地址。
Value:
'Fn::Sub':
- 'https://dtsnew.console.aliyun.com/sync/detail/manager/${MigrationJob}?regionId=${Region}'
- MigrationJob:
Fn::GetAtt:
- MigrationJob
- DtsJobId
Region:
Ref: ALIYUN::Region
RDSInstanceAddress:
Description:
en: RDS Instance address.
zh-cn: RDS实例访问地址。
Value:
Fn::Sub: https://rdsnext.console.aliyun.com/detail/${Database}/basicInfo?region=${ALIYUN::Region}
EcsLoginAddress:
Description:
en: ECS Login Address
zh-cn: ECS登录地址。
Value:
Fn::Sub: https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${WebServer}
Metadata:
ALIYUN::ROS::Interface:
Outputs:
- ECSInstanceUsername
- ECSInstancePassword
- WPUserForSQLUsername
- WPUserForSQLPassword
- RDSUserDTSUsername
- RDSUserDTSPassword
- RDSInternalAddress
ParameterGroups:
- Parameters:
- EcsInstanceType
- InstancePassword
- WPUserForSQLUsername
- WPUserForSQLPassword
Label:
default: ECS
- Parameters:
- DBInstanceEngineAndVersion
- DBInstanceClass
- RDSUserDTSUsername
- RDSUserDTSPassword
Label:
default: RDS
TemplateTags:
- acs:technical-solution:database:自建数据库迁移到云数据库-tech_solu_112
- acs:public_template:Solution:migrate-database-to-cloud
ALIYUN::ROS::Composer:
'34727653':
Res:
- VSwitch
Parent: 35402af3
Rect:
- 400
- 200
- 240
- 300
- 5
- 0
b7d6960a:
Rect:
- 815
- 602
- 40
- 80
- 1
- 0
ResT: Composer::ROSParameter::AlibabaCloud
afa6b141:
Parent: b7d6960a
Rect:
- 754
- 534
- 60
- 120
- 2
- 0
ResT: Composer::ROSParameter::Region
6abd97cd:
Res:
- RosWaitCondition
Parent: afa6b141
Rect:
- 40
- 40
- 320
- 560
- 3
- 0
2c041fd0:
Res:
- RosWaitConditionHandle
Parent: afa6b141
Rect:
- 40
- 40
- 452
- 560
- 3
- 0
520dd1f3:
Res:
- Vpc
Parent: afa6b141
Rect:
- 487
- 383
- 200
- 160
- 3
- 0
455ea1e7:
Res:
- RunCommand
Parent: afa6b141
Rect:
- 40
- 40
- 125
- 390
- 3
- 0
19a061fb:
Res:
- SecurityGroupIngress
Parent: afa6b141
Rect:
- 40
- 40
- 745
- 350
- 3
- 0
35402af3:
Res:
- Zone
Parent: 520dd1f3
Rect:
- 440
- 270
- 220
- 250
- 4
- 0
ResT: Composer::ROSParameter::Zone
65b719fd:
Res:
- SecurityGroup
Parent: 520dd1f3
Rect:
- 455
- 315
- 216
- 212
- 10
- 0
2a615dbe:
Parent: afa6b141
Edge:
- 6abd97cd
- 2c041fd0
Line: 0:0:0:gray:0
387f6f5d:
Parent: '34727653'
Edge:
- b6edc058
- f0baedae
Line: 0:0:0:gray:0
90756bef:
Parent: afa6b141
Edge:
- 19a061fb
- 65b719fd
Line: 0:0:0:gray:0
e99e0aa4:
Parent: afa6b141
Edge:
- 455ea1e7
- f0baedae
Line: 0:0:0:gray:0
f0baedae:
Res:
- WebServer
Parent: '34727653'
Rect:
- 40
- 40
- 337
- 390
- 11
- 0
Layer:
- 65b719fd
b6edc058:
Res:
- Database
Parent: '34727653'
Rect:
- 40
- 40
- 475
- 390
- 11
- 0
Layer:
- 65b719fd