forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
move-server-with-migration-tool.yml
604 lines (604 loc) · 18.9 KB
/
move-server-with-migration-tool.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
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
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: You can migrate servers running Windows or Linux from on-premises data centers,
VMs, or cloud platform hosts to Alibaba Cloud ECS. This template uses the Cloud
Migration tool to perform migration.
zh-cn: 适用需要迁移服务器到阿里云ECS,支持迁移主流Windows和Linux操作系统。包括P2V(Physical to Virtual)代表从物理
IDC 环境迁移到ECS,和V2V(Virtual to Virtual)代表从虚拟机环境或者云平台主机迁移到ECS;此模板搭建带有迁云工具的服务器。
Conditions:
CreateWindows:
Fn::Equals:
- win2012r2_64
- Ref: EcsGroupImageId
Parameters:
RamUserName:
Type: String
Label:
en: User Name
zh-cn: 用户名
Description:
en: 'User name, Length 1-64, consist of Capital letters, lowercase letters,
numbers, .@-_z. <br><b>note: <font color=''blue''>Unique in your account</b></font> '
zh-cn: 用户名,1-64个大小写字母、数字、.@-_z中的特殊符合组成。<br><b>注:<font color='blue'>帐号内唯一</b></font>
Default: migrationram
VpcCidrBlock:
Type: String
Label:
en: VPC Network Segment
zh-cn: 专有网络网段
Description:
en: 'The IP address range of the VPC in the CIDR Block form; <br>you can use
the following IP address ranges: <br><font color=''green''>[10.0.0.0/8]</font><br><font
color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
zh-cn: 专有网络IP地址段范围,<br>您可以使用以下的IP地址段:<br><font color='green'>[10.0.0.0/8]</font><br><font
color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
Default: 192.168.0.0/16
AllowedValues:
- 192.168.0.0/16
- 172.16.0.0/12
- 10.0.0.0/8
VSwZoneId:
Type: String
Label:
en: VSwitch Availability Zone
zh-cn: 交换机可用区
Description:
en: Availability zone id.<br><b>note: <font color='blue'>Before selecting the
availability zone, confirm that the availability Zone supports the creation
of ECS resources.</font></b>
zh-cn: 可用区Id。<br><b>注: <font color='blue'>选择可用区前请确认该可用区是否支持创建ECS资源。</font></b>
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
VSwCidrBlock:
Type: String
Label:
en: VSwitch Network Segment
zh-cn: 交换机网段
Description:
en: Must be a sub-network segment of the proprietary network and is not occupied
by other switches.
zh-cn: 必须是所属专有网络的子网段,并且没有被其他交换机占用。
Default: 192.168.0.0/16
EcsGroupMaxAmount:
Type: Number
Label:
en: ECS Amount
zh-cn: 实例数量
Description:
en: Number of instances, with values ranging from 1 to 100.
zh-cn: 实例数量,取值范围:1~100。
ConstraintDescription:
en: 'Valid value: 1 - 100.'
zh-cn: 取值范围:1~100。
Default: 1
MinValue: 1
MaxValue: 100
EcsGroupInstanceType:
Type: String
Label:
en: Specifications
zh-cn: 规格
Description:
en: 'Fill in the specifications that can be used under the VSwitch availability
zone;</b></font><br>general specifications:<font color=''red''><b>ecs.c5.large</b></font><br>note:
a few zones do not support general specifications<br>see detail: <a href=''https://www.alibabacloud.com/help/en/doc-detail/25378.html''
target=''_blank''><b><font color=''blue''>Instance Specification Family</font></a></b>'
zh-cn: 填写VSwitch可用区下可使用的规格;<br>通用规格:<font color='red'><b>ecs.c5.large</b></font><br>注:可用区可能不支持通用规格<br>规格详见:<a
href='https://help.aliyun.com/document_detail/25378.html' target='_blank'><b><font
color='blue'>实例规格族</font></a></b>
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: VSwZoneId
EcsGroupImageId:
Type: String
Label:
en: Image
zh-cn: 镜像
Description:
en: Image ID,see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html'
target='_blank'><font color='blue'>Find the mirror</font></a></b>
zh-cn: 镜像ID, 详见:<b><a href='https://help.aliyun.com/document_detail/112977.html'
target='_blank'><font color='blue'>查找镜像</font></a></b>
Default: centos_7
AllowedValues:
- centos_7
- win2012r2_64
EcsGroupSystemDiskCategory:
Type: String
Label:
en: System Disk Type
zh-cn: 系统盘类型
Description:
en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency:
<font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD
Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud:
<font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local
SSD Cloud Disk</font>]'
zh-cn: '<font color=''blue''><b>可选值:</b></font><br>[cloud_efficiency: <font
color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd:
<font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd:
<font color=''green''>本地SSD盘</font>]'
Default: cloud_ssd
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud
- cloud_essd
- ephemeral_ssd
EcsGroupSystemDiskSize:
Type: Number
Label:
en: System Disk Space
zh-cn: 系统盘空间
Description:
en: 'System disk size, range of values: 40-500, units: GB.'
zh-cn: 系统盘大小, 取值范围:[40, 500], 单位:GB。
ConstraintDescription:
en: 'Range of values: 40-500, units: GB.'
zh-cn: 取值范围:[40, 500], 单位:GB。
Default: 40
MinValue: 40
MaxValue: 500
EcsGroupPassword:
Type: String
Label:
en: Login Password
zh-cn: 登录密码
Description:
en: Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol
in).
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
MoveToRegion:
Type: String
Label:
en: ECS migration region
zh-cn: ECS迁移地域
Description:
en: Areas where ECS needs to be relocated.
zh-cn: ECS需要搬迁的地域。
Default: cn-zhangjiakou
AllowedValues:
- cn-chengdu
- cn-hangzhou
- cn-shanghai
- cn-qingdao
- cn-beijing
- cn-zhangjiakou
- cn-huhehaote
- cn-shenzhen
- cn-hongkong
- ap-southeast-1
- ap-southeast-2
- ap-southeast-3
- ap-southeast-5
- ap-northeast-1
- ap-south-1
- me-east-1
- eu-central-1
- eu-west-1
- us-west-1
- us-east-1
MoveToAliyunSystemDataSize:
Type: Number
Label:
en: Image system disk space
zh-cn: 镜像系统盘空间
Description:
en: 'Custom mirror system disk size, Valid value: 40-500, unit: GB.'
zh-cn: 自定义的镜像系统盘大小,取值范围40-500,单位:GB。
ConstraintDescription:
en: 'Valid Value: 40-500, unit: GB.'
zh-cn: 取值范围:40-500,单位:GB。
Default: 40
MinValue: 40
MaxValue: 500
Resources:
EcsVpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock
VpcName:
Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: 71970ddc-366a-4c60-95ab-88fd8a4497af
EcsSecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: EcsVpc
SecurityGroupEgress:
- DestCidrIp: 0.0.0.0/0
IpProtocol: all
NicType: intranet
PortRange: -1/-1
Priority: 1
SecurityGroupIngress:
- IpProtocol: all
NicType: internet
PortRange: -1/-1
Priority: 1
SourceCidrIp: 0.0.0.0/0
Metadata:
ALIYUN::ROS::Designer:
id: 9ed25729-6dcf-4a21-b810-2905cf4c10e5
EcsVSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: VSwZoneId
VpcId:
Ref: EcsVpc
CidrBlock:
Ref: VSwCidrBlock
VSwitchName:
Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: b31137b1-f6b3-4fec-bc03-342e80ec3860
RamUser:
Type: ALIYUN::RAM::User
Properties:
Policies:
- PolicyDocument:
Statement:
- Action:
- ecs:*
- vpc:DescribeVpcs
- vpc:DescribeVSwitches
- vpc:*HaVip*
- vpc:*RouteTable*
- vpc:*VRouter*
- vpc:*RouteEntry*
- vpc:*VSwitch*
- vpc:*Vpc*
- vpc:*Cen*
Effect: Allow
Resource:
- acs:ecs:*:*:*
- acs:vpc:*:*:*
Version: '1'
PolicyName:
Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackId
UserName:
Ref: RamUserName
Metadata:
ALIYUN::ROS::Designer:
id: 93a7c238-c9c2-4c29-b71a-3bec734d25b0
RamAccessKey:
Type: ALIYUN::RAM::AccessKey
Properties:
UserName:
Fn::GetAtt:
- RamUser
- UserName
DependsOn:
- RamUser
Metadata:
ALIYUN::ROS::Designer:
id: f15c0f55-2cde-4e76-8b0b-36f80b7288db
ECSInstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch
SecurityGroupId:
Ref: EcsSecurityGroup
ImageId:
Ref: EcsGroupImageId
AllocatePublicIP: true
InstanceType:
Ref: EcsGroupInstanceType
IoOptimized: optimized
MaxAmount:
Ref: EcsGroupMaxAmount
Password:
Ref: EcsGroupPassword
SystemDiskCategory:
Ref: EcsGroupSystemDiskCategory
SystemDiskSize:
Ref: EcsGroupSystemDiskSize
Tags:
- Key: best_practice
Value: '014'
UserData:
Fn::If:
- CreateWindows
- Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionHandle
- PowerShellCurlCli
- Fn::Join:
- ''
- - "[powershell] \r\n"
- "$client = new-object System.Net.WebClient \r\n"
- "$client.DownloadFile('http://p2v-tools.oss-cn-hangzhou.aliyuncs.com/smc/Alibaba_Cloud_Migration_Tool.zip',\
\ 'C:\\Alibaba_Cloud_Migration_Tool.zip') \r\n"
- "Expand-Archive -Path C:\\Alibaba_Cloud_Migration_Tool.zip -DestinationPath\
\ C:\\Alibaba_Cloud_Migration_Tool \r\n"
- "$name_info=Dir C:\\Alibaba_Cloud_Migration_Tool | Where-Object {\
\ $_.BaseName -match 'go2aliyun_client.*?_windows_x86_64' } \r\n"
- "$name_info -match 'go2aliyun_client.*?_windows_x86_64.zip' \r\n"
- "$name_and_suffix=$matches.values \r\n"
- "$name_info -match 'go2aliyun_client.*?_windows_x86_64' \r\n"
- "$name=$matches.values \r\n"
- "Expand-Archive -Path C:\\Alibaba_Cloud_Migration_Tool\\$name_and_suffix\
\ -DestinationPath C:\\Alibaba_Cloud_Migration_Tool\\go2aliyun \r\n"
- '$config = ''{"access_id": "'
- Fn::GetAtt:
- RamAccessKey
- AccessKeyId
- '", "secret_key": "'
- Fn::GetAtt:
- RamAccessKey
- AccessKeySecret
- '", "region_id": "'
- Ref: MoveToRegion
- '", "image_name": "'
- Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackName
- '", "system_disk_size": '
- Fn::Str:
Ref: MoveToAliyunSystemDataSize
- ", \"platform\": \"\", \"data_disks\": [], \"bandwidth_limit\": 0}'\
\ \r\n"
- "$config | Out-File C:\\Alibaba_Cloud_Migration_Tool\\go2aliyun\\\
$name\\user_config_bak.json \r\n"
- "Get-Content C:\\Alibaba_Cloud_Migration_Tool\\go2aliyun\\$name\\\
user_config_bak.json | set-Content C:\\Alibaba_Cloud_Migration_Tool\\\
go2aliyun\\$name\\user_config.json \r\n"
- "ros-notify \r\n"
- Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionHandle
- CurlCli
- Fn::Join:
- ''
- - "#!/bin/sh \n"
- imagename=
- Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackId
- " \n"
- region=
- Ref: MoveToRegion
- " \n"
- ak=
- Fn::GetAtt:
- RamAccessKey
- AccessKeyId
- " \n"
- sk=
- Fn::GetAtt:
- RamAccessKey
- AccessKeySecret
- " \n"
- size=
- Fn::Str:
Ref: MoveToAliyunSystemDataSize
- " \n"
- "cd ~ \n"
- "echo \"{\\\"access_id\\\": \\\"$ak\\\", \\\"secret_key\\\": \\\"\
$sk\\\", \\\"region_id\\\": \\\"$region\\\", \\\"image_name\\\": \\\
\"$imagename\\\", \\\"system_disk_size\\\": $size, \\\"platform\\\"\
: \\\"\\\", \\\"data_disks\\\": [], \\\"bandwidth_limit\\\": 0}\"\
\ > user_config.json \n"
- "yum -y install unzip \n"
- "wget http://p2v-tools.oss-cn-hangzhou.aliyuncs.com/smc/Alibaba_Cloud_Migration_Tool.zip\
\ \n"
- "unzip Alibaba_Cloud_Migration_Tool.zip \n"
- "unzip go2aliyun_client*linux_x86_64.zip \n"
- "mv go2aliyun_client*linux_x86_64 go2aliyun \n"
- "mv go2aliyun/user_config.json go2aliyun/user_config.json.bak \n"
- "cp user_config.json go2aliyun/ \n"
- "cd go2aliyun \n"
- "chmod +x go2aliyun_client \n"
- "ros-notify -d \"{\\\"Data\\\" : \\\"SUCCESS\\\", \\\"Status\\\" :\
\ \\\"SUCCESS\\\"}\" \n"
DependsOn:
- RamAccessKey
Metadata:
ALIYUN::ROS::Designer:
id: 525992bf-bafc-4ee4-aaa6-9a15e0e574dd
RosWaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
Metadata:
ALIYUN::ROS::Designer:
id: 3c3114b6-b7be-4c4c-9ab6-dc85eece60fb
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: RosWaitConditionHandle
Timeout: 600
Metadata:
ALIYUN::ROS::Designer:
id: 7296be89-7011-4f4a-8749-5e90298a6fcc
Outputs:
AccessKeyId:
Value:
Fn::GetAtt:
- RamAccessKey
- AccessKeyId
CreateDate:
Value:
Fn::GetAtt:
- RamUser
- CreateDate
UserId:
Value:
Fn::GetAtt:
- RamUser
- UserId
UserName:
Value:
Fn::GetAtt:
- RamUser
- UserName
WinECSInstanceIds:
Value:
Fn::GetAtt:
- ECSInstanceGroup
- InstanceIds
WinECSPrivateIps:
Value:
Fn::GetAtt:
- ECSInstanceGroup
- PrivateIps
WinECSPublicIps:
Value:
Fn::GetAtt:
- ECSInstanceGroup
- PublicIps
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- RamUserName
Label:
default: RAM
- Parameters:
- VpcCidrBlock
- VSwZoneId
- VSwCidrBlock
Label:
default: VPC
- Parameters:
- EcsGroupMaxAmount
- EcsGroupInstanceType
- EcsGroupImageId
- EcsGroupSystemDiskCategory
- EcsGroupSystemDiskSize
- EcsGroupPassword
Label:
default: ECS
- Parameters:
- MoveToRegion
- MoveToAliyunSystemDataSize
Label:
default:
en: Migration Info
zh-cn: 迁移信息
TemplateTags:
- acs:solution:业务上云:服务器迁移-搭建带有迁云工具的服务器
ALIYUN::ROS::Designer:
13758b49-7d22-4e83-aca5-e37b06f3ed5d:
source:
id: f15c0f55-2cde-4e76-8b0b-36f80b7288db
target:
id: 93a7c238-c9c2-4c29-b71a-3bec734d25b0
z: 1
3b96c45c-fb96-49ef-8f67-083875638b93:
source:
id: 525992bf-bafc-4ee4-aaa6-9a15e0e574dd
target:
id: f15c0f55-2cde-4e76-8b0b-36f80b7288db
z: 1
3c3114b6-b7be-4c4c-9ab6-dc85eece60fb:
position:
x: 86
y: 96
size:
height: 60
width: 60
z: 0
525992bf-bafc-4ee4-aaa6-9a15e0e574dd:
position:
x: 254
y: 174
size:
height: 60
width: 60
z: 2
71970ddc-366a-4c60-95ab-88fd8a4497af:
embeds:
- b31137b1-f6b3-4fec-bc03-342e80ec3860
- 9ed25729-6dcf-4a21-b810-2905cf4c10e5
position:
x: 191
y: 50
size:
height: 288
width: 317.0537109375
z: 0
7296be89-7011-4f4a-8749-5e90298a6fcc:
position:
x: 86
y: 236
size:
height: 60
width: 60
z: 0
93a7c238-c9c2-4c29-b71a-3bec734d25b0:
position:
x: 409
y: 360
size:
height: 60
width: 60
z: 0
9ed25729-6dcf-4a21-b810-2905cf4c10e5:
position:
x: 402
y: 174
size:
height: 60
width: 60
z: 1
b31137b1-f6b3-4fec-bc03-342e80ec3860:
embeds:
- 525992bf-bafc-4ee4-aaa6-9a15e0e574dd
position:
x: 216
y: 134
size:
height: 141
width: 131
z: 1
b3c701e4-51e9-467f-95d6-4e51f2049fd5:
source:
id: 7296be89-7011-4f4a-8749-5e90298a6fcc
target:
id: 3c3114b6-b7be-4c4c-9ab6-dc85eece60fb
z: 1
db2ba12d-f329-4603-a7c4-99c73d90d3ac:
source:
id: 525992bf-bafc-4ee4-aaa6-9a15e0e574dd
target:
id: 9ed25729-6dcf-4a21-b810-2905cf4c10e5
z: 1
f15c0f55-2cde-4e76-8b0b-36f80b7288db:
position:
x: 254
y: 360
size:
height: 60
width: 60
z: 0