forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathe-commerce-business-and-db-on-the-cloud.yml
1047 lines (1047 loc) · 36.7 KB
/
e-commerce-business-and-db-on-the-cloud.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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: This template can create the resources required for e-commerce website building
and database migration solutions. It serves as one of the best practices for enterprises
to migrate to the cloud.
zh-cn: 此模板可创建出电商资源建站和数据库迁移方案所需资源,属于企业上云的最佳实践之一。
Parameters:
VpcCidrBlock1:
Type: String
Label:
en: VPC CIDR Block
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:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
VSwitchZoneId1:
Type: String
Label:
en: Available Zone
zh-cn: 可用区
Description:
en: Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please
confirm that the Availability Zone supports the specification of creating
RDS and ECS resources</font></b>
zh-cn: 可用区ID。<br><b>注: <font color='blue'>选择可用区前请确认该可用区是否支持创建RDS和ECS资源的规格</font></b>
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
VSwitchCidrBlock1:
Type: String
Label:
en: VSwitch CIDR Block
zh-cn: 交换机网段
Description:
en: Must be a sub-network segment of the proprietary network and is not occupied
by other VSwitches.
zh-cn: 必须是所属专有网络的子网段,并且没有被其他交换机占用。
Default: 192.168.2.0/24
EipBandwidth:
Type: Number
Label:
en: EIP Bandwidth
zh-cn: 弹性IP带宽峰值
Description:
en: 'Value range: [1, 1000], unit: Mbps.'
zh-cn: '取值范围: [1, 1000],单位:Mbps。'
ConstraintDescription:
en: 'Value range: [1, 1000], unit: Mbps.'
zh-cn: '取值范围: [1, 1000],单位:Mbps。'
Default: 2
MinValue: 1
MaxValue: 1000
EcsInstanceType:
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: VSwitchZoneId1
InstanceImageId:
Type: String
Label:
en: Image
zh-cn: 镜像
Description:
en: 'Server instance 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: 服务器镜像,详见:<b><a href='https://help.aliyun.com/document_detail/112977.html'
target='_blank'><font color='blue'>查找镜像</font></a></b>
AssociationProperty: ALIYUN::ECS::Instance:ImageId
Default: centos_7_06_64_20G_alibase_20190711.vhd
EcsSystemDiskCategory:
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_efficiency
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud
- cloud_essd
- ephemeral_ssd
EcsSystemDiskSize:
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: 'System disk size, range of values: 40-500, units: GB.'
zh-cn: 系统盘大小, 取值范围:[40, 500], 单位:GB。
Default: 40
MinValue: 40
MaxValue: 500
EcsPassword:
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
DataBase1:
Type: String
Label:
en: Database Name
zh-cn: 数据库名称
Description:
en: The database name created by the instance, consisting of lowercase letters,
numbers, underscores, and middle lines, beginning with letters, ending with
letters or numbers, up to 64 characters.
zh-cn: 实例创建的数据库名称,由小写字母、数字、下划线、中划线组成,以字母开头,字母或数字结尾,最多64个字符。
ConstraintDescription:
en: Consisting of lowercase letters, numbers, underscores, and middle lines,
beginning with letters, ending with letters or numbers, up to 64 characters.
zh-cn: 由小写字母、数字、下划线、中划线组成,以字母开头,字母或数字结尾,最多64个字符。
Default: demodb
MinLength: 1
MaxLength: 64
DBTable:
Type: String
Label:
en: Table Name
zh-cn: 表名
Description:
en: Table name for testing, 1-64 characters, English letters, Numbers and the
underscore '_' are recommended.
zh-cn: 用于测试的表名, 1-64个字符,建议使用英文字母、数字及下划线“_”。
ConstraintDescription:
en: 1-64 characters, English letters, Numbers and the underscore '_' are recommended.
zh-cn: 1—64个字符,建议使用英文字母、数字及下划线“_”。
Default: demo_dplus_buyer
MinLength: 1
MaxLength: 64
MysqlPassword:
Type: String
Label:
en: Root Account Password
zh-cn: root用户密码
Description:
en: Root password for MySQL application (non-rds instance).
zh-cn: MySQL应用的root用户密码(非rds实例)。
ConstraintDescription:
en: Length in 5-30 bits
zh-cn: 5~30个字符
MinLength: 5
MaxLength: 30
NoEcho: true
DtsUser:
Type: String
Label:
en: Migration User
zh-cn: 迁移用户
Description:
en: Create the migration using MySQL user, grant copy account permissions, <br>up
to 16 characters, consisting of lowercase letters, Numbers, underscores, beginning
letters, and ending letters or Numbers.
zh-cn: 创建迁移用MySQL用户,授予复制账号权限, <br>最长16个字符, 由小写字母,数字、下划线组成、字母开头,字母或数字结尾。
ConstraintDescription:
en: 1-16 characters, consisting of lowercase letters, Numbers, underscores,
beginning letters, and ending letters or Numbers.
zh-cn: 1-16个字符, 由小写字母,数字、下划线组成、字母开头,字母或数字结尾。
Default: dtssync
MinLength: 1
MaxLength: 16
DtsPassword:
Type: String
Label:
en: Migrate User Password
zh-cn: 迁移用户密码
Description:
en: MySQL migration user password, root password for MySQL application (non-rds
instance).
zh-cn: MySQL迁移用户密码,MySQL应用的root用户密码(非rds实例)。
ConstraintDescription:
en: ' Length in 8-32 bits'
zh-cn: 长度为8-32位
MinLength: 8
MaxLength: 32
NoEcho: true
DBInstanceEngineAndVersion:
Type: String
Label:
en: Type And Version
zh-cn: 类型与版本号
Description:
en: Database type and version number.
zh-cn: 数据库类型与版本号。
Default: MySQL-5.6
AllowedValues:
- MySQL-5.5
- MySQL-5.6
- MySQL-5.7
- MySQL-8.0
DBInstanceClass:
Type: String
Label:
en: Specifications
zh-cn: 规格
Description:
en: 'Select the instance specification based on the type of database engine
and the available area support;<br>see detail: <a href=''https://www.alibabacloud.com/help/doc-detail/26312.html''
target=''_blank''><b><font color=''blue''>Instance specification sheet</font></b></a>'
zh-cn: 根据数据库引擎的类型和可用的区域支持选择实例规格;<br>请参见详细信息:<a href='https://help.aliyun.com/document_detail/26312.html'
target='_blank'><b><font color='blue'>实例规格表</font></b></a>
Default: rds.mysql.s2.large
DBInstanceStorage:
Type: Number
Label:
en: Storage Space
zh-cn: 存储空间
Description:
en: 'Database storage space, units: GB, per 5GB increment, value range: 20-1000.'
zh-cn: 数据库存储空间, 单位:GB, 每5GB进行递增,取值范围:20-1000。
ConstraintDescription:
en: 'Database storage space, units: GB, per 5GB increment, value range: 20-1000.'
zh-cn: 数据库存储空间, 单位:GB, 每5GB进行递增,取值范围:20-1000。
Default: 200
MinValue: 50
MaxValue: 1000
DBName:
Type: String
Label:
en: Database Name
zh-cn: 数据库名称
Description:
en: The database name created by the instance, consisting of lowercase letters,
numbers, underscores, and middle lines, beginning with letters, ending with
letters or numbers, up to 64 characters.
zh-cn: 实例创建的数据库名称,由小写字母、数字、下划线、中划线组成,以字母开头,字母或数字结尾,最多64个字符。
Default: dbname01
RdsUserName:
Type: String
Label:
en: Database Account
zh-cn: 数据库账号
Description:
en: The user name of a high-privilege account, consisting of lowercase letters,
Numbers, and underscores, begins with a letter, ends with a letter or number,
and is 2-16 characters long.
zh-cn: 高权限账号用户名,由小写字母,数字、下划线组成,以字母开头,字母或数字结尾,2-16个字符。
ConstraintDescription:
en: The user name of a high-privilege account, consisting of lowercase letters,
Numbers, and underscores, begins with a letter, ends with a letter or number,
and is 2-16 characters long.
zh-cn: 高权限账号用户名,由小写字母,数字、下划线组成,以字母开头,字母或数字结尾,2-16个字符。
Default: myuser
MinLength: 2
MaxLength: 16
RdsUserPassword:
Type: String
Label:
en: Account Password
zh-cn: 帐号密码
Description:
en: 'High-privilege user account password, big/lowercase letters, Numbers, special
characters account for three, length of 8-32 bits;Special characters included!@
# $% ^ & * () _ + - =.'
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
DtsMigrationJobClass:
Type: String
Label:
en: Migration Instance Specification
zh-cn: 迁移实例规格
Description:
en: Specifications of data migration channels;<br>see detail:<a href='https://www.alibabacloud.com/help/doc-detail/26606.html'
target='_blank'><b><font color='blue'>Specifications</font></b></a>
zh-cn: 迁移实例规格;<br>规格详见:<a href='https://help.aliyun.com/document_detail/26606.html'
target='_blank'><b><font color='blue'>规格说明</font></b></a>
Default: small
AllowedValues:
- small
- medium
- large
DtsMigrationJobName:
Type: String
Label:
en: Migration Task Name
zh-cn: 迁移任务名称
Description:
en: Migration Task Name
zh-cn: 迁移任务名称
Default: testmigration
Resources:
EcsVpc1App:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock1
VpcName:
Fn::Join:
- '-'
- - Vpc1
- StackId
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: d69fc413-e9bd-43b1-bdd0-61ce90a4324b
EcsSecurityGroup1:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: EcsVpc1App
SecurityGroupIngress:
- IpProtocol: tcp
Policy: accept
PortRange: 22/22
Priority: 1
SourceCidrIp: 0.0.0.0/0
- IpProtocol: tcp
Policy: accept
PortRange: 3306/3306
Priority: 1
SourceCidrIp: 0.0.0.0/0
- IpProtocol: tcp
Policy: accept
PortRange: 80/80
Priority: 1
SourceCidrIp: 0.0.0.0/0
SecurityGroupName:
Fn::Join:
- '-'
- - SecurityGroup1
- StackId
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: 7048f43a-802a-465a-ad80-599eb9c22425
EcsVSwitch1:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: VSwitchZoneId1
VpcId:
Ref: EcsVpc1App
CidrBlock:
Ref: VSwitchCidrBlock1
VSwitchName:
Fn::Join:
- '-'
- - VSwitch1
- StackId
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: 3dff451e-ba57-4f66-b1e0-65fe3d81e417
EcsInstance2:
Type: ALIYUN::ECS::Instance
Properties:
VpcId:
Ref: EcsVpc1App
VSwitchId:
Ref: EcsVSwitch1
SecurityGroupId:
Ref: EcsSecurityGroup1
ImageId:
Ref: InstanceImageId
AllocatePublicIP: false
InstanceType:
Ref: EcsInstanceType
IoOptimized: optimized
Password:
Ref: EcsPassword
Tags:
- Key: 008
Value: best_practice
- Key: 订单应用
Value: 自建数据库
UserData:
Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionHandle
- CurlCli
- Fn::Join:
- ''
- - "#!/bin/sh \n"
- rootpwd=
- Ref: MysqlPassword
- " \n"
- data_base1=
- Ref: DataBase1
- " \n"
- DtsUser=
- Ref: DtsUser
- " \n"
- DtsPwd=
- Ref: DtsPassword
- " \n"
- db_table=
- Ref: DBTable
- " \n"
- "cd ~ \n"
- "sleep 120 \n"
- "wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm\
\ \n"
- "rpm -ivh mysql-community-release-el6-5.noarch.rpm \n"
- "yum repolist all | grep mysql \n"
- "yum install mysql-community-server -y \n"
- "# 生成MySQL root用户,设置密码 \n"
- "echo \\#\\!/bin/bash > dbroot.sh \n"
- "echo MYSQL_PASSWD=\\\"$rootpwd\\\" >> dbroot.sh \n"
- "echo service mysqld start >> dbroot.sh \n"
- "echo yum install expect -y >> dbroot.sh \n"
- "echo \"echo '#!/usr/bin/expect\" >> dbroot.sh \n"
- "echo set timeout 60 >> dbroot.sh \n"
- "echo 'set password [lindex $argv 0]' >> dbroot.sh \n"
- "echo spawn mysql_secure_installation >> dbroot.sh \n"
- "echo expect { >> dbroot.sh \n"
- "echo \\\"enter for none\\\" { send \\\"\\\\r\\\"\\; exp_continue} >>\
\ dbroot.sh \n"
- "echo \\\"Y/n\\\" { send \\\"Y\\\\r\\\" \\; exp_continue} >> dbroot.sh\
\ \n"
- "echo '\"password\" { send \"$password\\r\"; exp_continue}' >> dbroot.sh\
\ \n"
- "echo \\\"Cleaning up\\\" { send \\\"\\\\r\\\"} >> dbroot.sh \n"
- "echo } >> dbroot.sh \n"
- "echo \"interact ' > mysql_secure_installation.exp\" >> dbroot.sh \n"
- "echo chmod +x mysql_secure_installation.exp >> dbroot.sh \n"
- "echo './mysql_secure_installation.exp $MYSQL_PASSWD' >> dbroot.sh \n"
- "chmod +x dbroot.sh \n"
- "./dbroot.sh \n"
- "# 数据库配置文件初始化 \n"
- "cp /etc/my.cnf /etc/my.cnf.bak \n"
- "echo '[mysqld]' > /etc/my.cnf \n"
- "echo 'server_id=2' >> /etc/my.cnf \n"
- "echo 'innodb_buffer_pool_size = 8G' >> /etc/my.cnf \n"
- "echo 'port = 3306' >> /etc/my.cnf \n"
- "echo 'max_connections = 1000 ' >> /etc/my.cnf \n"
- "echo 'max_user_connections = 1000 ' >> /etc/my.cnf \n"
- "echo 'table_open_cache = 10240 ' >> /etc/my.cnf \n"
- "echo 'table_definition_cache = 2048 ' >> /etc/my.cnf \n"
- "echo 'open_files_limit = 65535 ' >> /etc/my.cnf \n"
- "echo 'innodb_open_files = 65535' >> /etc/my.cnf \n"
- "echo 'innodb_log_file_size = 100M ' >> /etc/my.cnf \n"
- "echo 'innodb_log_files_in_group = 2 ' >> /etc/my.cnf \n"
- "echo 'lower_case_table_names = 1' >> /etc/my.cnf \n"
- "echo 'collation_server = utf8_bin' >> /etc/my.cnf \n"
- "echo 'character_set_server = utf8' >> /etc/my.cnf \n"
- "echo 'skip_name_resolve' >> /etc/my.cnf \n"
- "echo 'skip-external-locking' >> /etc/my.cnf \n"
- "echo 'explicit_defaults_for_timestamp ' >> /etc/my.cnf \n"
- "echo 'back_log = 1024' >> /etc/my.cnf \n"
- "echo 'thread_cache_size = 512 ' >> /etc/my.cnf \n"
- "echo 'max_connect_errors = 2000 ' >> /etc/my.cnf \n"
- "echo 'table_open_cache_instances = 16' >> /etc/my.cnf \n"
- "echo 'binlog_cache_size = 512K' >> /etc/my.cnf \n"
- "echo 'bulk_insert_buffer_size = 64M' >> /etc/my.cnf \n"
- "echo 'ft_min_word_len = 4' >> /etc/my.cnf \n"
- "echo 'key_buffer_size = 32M' >> /etc/my.cnf \n"
- "echo 'max_allowed_packet = 1024M' >> /etc/my.cnf \n"
- "echo 'max_heap_table_size = 32M' >> /etc/my.cnf \n"
- "echo 'tmp_table_size = 32M' >> /etc/my.cnf \n"
- "echo 'myisam_max_sort_file_size = 10G' >> /etc/my.cnf \n"
- "echo 'myisam_repair_threads = 1' >> /etc/my.cnf \n"
- "echo 'myisam_sort_buffer_size = 24M' >> /etc/my.cnf \n"
- "echo 'query_cache_limit = 1M' >> /etc/my.cnf \n"
- "echo 'query_cache_size = 0' >> /etc/my.cnf \n"
- "echo 'sort_buffer_size = 4M' >> /etc/my.cnf \n"
- "echo 'join_buffer_size = 6M' >> /etc/my.cnf \n"
- "echo 'read_buffer_size = 2M' >> /etc/my.cnf \n"
- "echo 'read_rnd_buffer_size = 3M' >> /etc/my.cnf \n"
- "echo 'thread_stack = 192K' >> /etc/my.cnf \n"
- "echo '# log' >> /etc/my.cnf \n"
- "echo 'general_log = off ' >> /etc/my.cnf \n"
- "echo 'log_bin=on' >> /etc/my.cnf \n"
- "echo 'binlog_format=ROW' >> /etc/my.cnf \n"
- "echo '#' >> /etc/my.cnf \n"
- "echo 'datadir=/var/lib/mysql' >> /etc/my.cnf \n"
- "echo 'socket=/var/lib/mysql/mysql.sock' >> /etc/my.cnf \n"
- "echo '' >> /etc/my.cnf \n"
- "echo 'symbolic-links=0' >> /etc/my.cnf \n"
- "echo '' >> /etc/my.cnf \n"
- "echo 'sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES' >> /etc/my.cnf\
\ \n"
- "echo '' >> /etc/my.cnf \n"
- "echo '[mysql_safe]' >> /etc/my.cnf \n"
- "echo 'log-error=/var/log/mysqld.log' >> /etc/my.cnf \n"
- "echo 'pid-file=/var/run/mysqld/mysqld.pid' >> /etc/my.cnf \n"
- "service mysqld restart \n"
- "# 操作系统层面数据库优化 \n"
- "echo 'ulimit -u 65535' >> /etc/profile \n"
- "echo 'ulimit -n 65535' >> /etc/profile \n"
- "echo 'ulimit -d unlimited' >> /etc/profile \n"
- "echo 'ulimit -m unlimited' >> /etc/profile \n"
- "echo 'ulimit -s unlimited' >> /etc/profile \n"
- "echo 'ulimit -t unlimited' >> /etc/profile \n"
- "echo 'ulimit -v unlimited' >> /etc/profile \n"
- "source /etc/profile \n"
- "# 创建数据库、表,插入测试数据 \n"
- "echo \\#\\!/bin/bash > db.sh \n"
- "echo mysql -uroot -p\"$rootpwd\" \\<\\<EOF >> db.sh \n"
- "echo CREATE DATABASE IF NOT EXISTS \"$data_base1\" DEFAULT CHARSET\
\ utf8 COLLATE utf8_general_ci\\; >> db.sh \n"
- "echo create user \"$DtsUser\" identified by \\\"$DtsPwd\\\"\\; >> db.sh\
\ \n"
- "echo grant REPLICATION CLIENT, REPLICATION SLAVE, select, SHOW VIEW\
\ on \\*.* to \"$DtsUser\"@\\\"%\\\" identified by \\\"$DtsPwd\\\"\\\
; >> db.sh \n"
- "echo flush privileges\\; >> db.sh \n"
- "echo use \"$data_base1\"\\; >> db.sh \n"
- "echo DROP TABLE IF EXISTS demo_data\\; >> db.sh \n"
- "echo CREATE TABLE \"$db_table\" \\( >> db.sh \n"
- "echo buyer_id varchar\\(32\\) DEFAULT NULL , >> db.sh \n"
- "echo buyer_prov varchar\\(32\\) DEFAULT NULL , >> db.sh \n"
- "echo gender varchar\\(32\\) DEFAULT NULL , >> db.sh \n"
- "echo age_range varchar\\(32\\) DEFAULT NULL , >> db.sh \n"
- "echo zodiac varchar\\(32\\) DEFAULT NULL >> db.sh \n"
- "echo \\) ENGINE=InnoDB DEFAULT CHARSET=utf8\\; >> db.sh \n"
- "echo insert into \"$db_table\"\\(\"buyer_id\",\"buyer_prov\",\"gender\"\
,\"age_range\",\"zodiac\"\\) values >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\), >> db.sh \n"
- "echo \\(\\\"00047f4d5e5c\\\",\\\"ShangXI\\\",\\\"M\\\",\\\"20-30\\\"\
,\\\"by\\\"\\)\\; >> db.sh \n"
- "echo EOF >> db.sh \n"
- "chmod +x db.sh \n"
- "./db.sh \n"
- "ros-notify -d \"{\\\"Data\\\" : \\\"SUCCESS\\\", \\\"Status\\\" : \\\
\"SUCCESS\\\"}\" \n"
Metadata:
ALIYUN::ROS::Designer:
id: 82bd9f90-89db-4bd4-8cac-bbff00f0abe8
RdsDBInstance:
Type: ALIYUN::RDS::DBInstance
Properties:
VpcId:
Ref: EcsVpc1App
VSwitchId:
Ref: EcsVSwitch1
DBInstanceClass:
Ref: DBInstanceClass
DBInstanceStorage:
Ref: DBInstanceStorage
DBMappings:
- CharacterSetName: utf8
DBName:
Ref: DBName
Engine:
Fn::Select:
- '0'
- Fn::Split:
- '-'
- Ref: DBInstanceEngineAndVersion
EngineVersion:
Fn::Select:
- '1'
- Fn::Split:
- '-'
- Ref: DBInstanceEngineAndVersion
MasterUserPassword:
Ref: RdsUserPassword
MasterUserType: Super
MasterUsername:
Ref: RdsUserName
MultiAZ: true
SecurityIPList:
Ref: VpcCidrBlock1
Tags:
Key: best_practice
Value: 008
Metadata:
ALIYUN::ROS::Designer:
id: c46d890c-2bfc-43ec-9817-149c298afe5a
RosWaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
Metadata:
ALIYUN::ROS::Designer:
id: a68c9746-06fe-4f8e-94e2-10f8eed1435a
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: RosWaitConditionHandle
Timeout: 600
Metadata:
ALIYUN::ROS::Designer:
id: 287657df-217f-4594-823e-a7bda06c3bbd
VpcEip2:
Type: ALIYUN::VPC::EIP
Properties:
Bandwidth:
Ref: EipBandwidth
InstanceChargeType: Postpaid
InternetChargeType: PayByTraffic
Metadata:
ALIYUN::ROS::Designer:
id: 6dfdde06-4467-4182-9f68-384e86c5f3c3
DtsMigrationJob:
Type: ALIYUN::DTS::MigrationJob
Properties:
DestinationEndpoint:
EngineName: MySQL
InstanceID:
Ref: RdsDBInstance
InstanceType: RDS
Password:
Ref: RdsUserPassword
Port: '3306'
Region:
Ref: ALIYUN::Region
UserName:
Ref: RdsUserName
MigrationJobClass:
Ref: DtsMigrationJobClass
MigrationJobName:
Ref: DtsMigrationJobName
MigrationMode:
DataIntialization: true
DataSynchronization: true
StructureIntialization: true
MigrationObject:
- DBName:
Ref: DataBase1
NewDBName:
Ref: DBName
NewSchemaName:
Ref: DBName
SchemaName:
Ref: DataBase1
SourceEndpoint:
EngineName: MySQL
IP:
Fn::GetAtt:
- VpcEip2
- EipAddress
InstanceID:
Ref: EcsInstance2
InstanceType: ECS
Password:
Ref: DtsPassword
Port: '3306'
Region:
Ref: ALIYUN::Region
UserName:
Ref: DtsUser
DependsOn:
- RdsDBInstance
- RosWaitCondition
Metadata:
ALIYUN::ROS::Designer:
id: 718b893a-fc3a-4f22-a694-16148f45276a
EcsInstance1:
Type: ALIYUN::ECS::Instance
Properties:
VpcId:
Ref: EcsVpc1App
VSwitchId:
Ref: EcsVSwitch1
SecurityGroupId:
Ref: EcsSecurityGroup1
ImageId:
Ref: InstanceImageId
AllocatePublicIP: false
InstanceType:
Ref: EcsInstanceType
IoOptimized: optimized
Password:
Ref: EcsPassword
SystemDiskCategory:
Ref: EcsSystemDiskCategory
SystemDiskSize:
Ref: EcsSystemDiskSize
Tags:
- Key: 008
Value: best_practice
- Key: 订单应用
Value: 业务
Metadata:
ALIYUN::ROS::Designer:
id: 2dffdc22-4c50-4209-8454-96146fd8d3a3
VpcEip1:
Type: ALIYUN::VPC::EIP
Properties:
Bandwidth:
Ref: EipBandwidth
InstanceChargeType: Postpaid
InternetChargeType: PayByTraffic
Metadata:
ALIYUN::ROS::Designer:
id: 0d95dec1-3713-4205-8551-9426e88432b0
VpcEipAssociation1:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Ref: EcsInstance1
AllocationId:
Ref: VpcEip1
DependsOn:
- EcsInstance1
- VpcEip1
Metadata:
ALIYUN::ROS::Designer:
id: b3feba84-6737-4890-8202-3661ebfea58b
VpcEipAssociation2:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Ref: EcsInstance2
AllocationId:
Ref: VpcEip2
DependsOn:
- EcsInstance2
- VpcEip2
Metadata:
ALIYUN::ROS::Designer:
id: dda1f1d3-6048-4ae3-baa3-131166ed4911
Outputs:
Instance1Eip:
Description:
en: The public network IP of the resource server.
zh-cn: APP资源服务器的公网IP。
Value:
Fn::GetAtt:
- VpcEip1
- EipAddress
Instance1Id:
Description:
en: The instance ID of the resource server.
zh-cn: APP资源服务器的实例ID。
Value:
Fn::GetAtt:
- EcsInstance1
- InstanceId
Instance2EId:
Description:
en: The instance ID of your own database server.
zh-cn: 自建数据库服务器的实例ID
Value:
Fn::GetAtt:
- EcsInstance2
- InstanceId
Instance2Eip:
Description:
en: Self-built database server public network IP.
zh-cn: 自建数据库服务器的公网IP。
Value:
Fn::GetAtt:
- VpcEip2
- EipAddress
RdsAccount:
Description:
en: RDS high privilege account.
zh-cn: RDS高权限帐号。
Value:
Ref: RdsUserName
RdsInstanceId:
Description:
en: RDS Instance ID.
zh-cn: RDS实例ID。
Value:
Fn::GetAtt:
- RdsDBInstance
- DBInstanceId
RdsInstanceInnerConnectionString:
Description:
en: RDS Intranet connection string.
zh-cn: RDS内网连接串。
Value:
Fn::GetAtt:
- RdsDBInstance
- InnerConnectionString
SelfBuildMySQLAccount:
Description:
en: Self Build MySQLA ccount.
zh-cn: 自建数据库迁移用户账号。
Value:
Ref: DtsUser
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- VpcCidrBlock1
- VSwitchZoneId1
- VSwitchCidrBlock1
- EipBandwidth
Label:
default: VPC
- Parameters:
- EcsInstanceType
- InstanceImageId
- EcsSystemDiskCategory
- EcsSystemDiskSize
- EcsPassword
Label:
default: ECS
- Parameters:
- DataBase1
- DBTable
- MysqlPassword
- DtsUser
- DtsPassword
Label:
default: APP MYSQL
- Parameters:
- DBInstanceEngineAndVersion
- DBInstanceClass
- DBInstanceStorage
- DBName
- RdsUserName
- RdsUserPassword
Label:
default: RDS
- Parameters:
- DtsMigrationJobClass
- DtsMigrationJobName
Label:
default: DTS
TemplateTags:
- acs:solution:业务上云:电商行业业务及数据库上云
ALIYUN::ROS::Designer:
0d95dec1-3713-4205-8551-9426e88432b0:
position:
x: 53
y: 350
size:
height: 60
width: 60
z: 0
287657df-217f-4594-823e-a7bda06c3bbd:
position:
x: 730
y: 236
size:
height: 60
width: 60
z: 0
2dffdc22-4c50-4209-8454-96146fd8d3a3:
position:
x: 218
y: 212
size:
height: 60
width: 60
z: 2
3dff451e-ba57-4f66-b1e0-65fe3d81e417:
embeds:
- c46d890c-2bfc-43ec-9817-149c298afe5a
- 82bd9f90-89db-4bd4-8cac-bbff00f0abe8
- 2dffdc22-4c50-4209-8454-96146fd8d3a3
position:
x: 179
y: 72
size:
height: 251
width: 222
z: 1
44a468ac-f818-4302-8d11-2615e65cffb2:
source:
id: 2dffdc22-4c50-4209-8454-96146fd8d3a3
target:
id: 7048f43a-802a-465a-ad80-599eb9c22425
z: 1
5f0a782d-42e6-421f-b36b-df83a277a49b:
source:
id: dda1f1d3-6048-4ae3-baa3-131166ed4911
target:
id: 6dfdde06-4467-4182-9f68-384e86c5f3c3
z: 1
6dfdde06-4467-4182-9f68-384e86c5f3c3:
position:
x: 721
y: 112
size:
height: 60
width: 60
z: 0
7048f43a-802a-465a-ad80-599eb9c22425:
position:
x: 318
y: 332
size:
height: 60
width: 60
z: 1
718b893a-fc3a-4f22-a694-16148f45276a:
position:
x: 561
y: 342
size:
height: 60
width: 60
z: 0
82bd9f90-89db-4bd4-8cac-bbff00f0abe8:
position:
x: 318
y: 112
size:
height: 60
width: 60
z: 2
9c347be2-0e45-4ae4-8aef-ce9db042170d:
source:
id: 287657df-217f-4594-823e-a7bda06c3bbd
target:
id: a68c9746-06fe-4f8e-94e2-10f8eed1435a
z: 1
a68c9746-06fe-4f8e-94e2-10f8eed1435a:
position:
x: 565
y: 236
size:
height: 60
width: 60
z: 0
b1afbb51-c8d6-46eb-9cc2-262a6afb873b:
source:
id: 82bd9f90-89db-4bd4-8cac-bbff00f0abe8
target:
id: 7048f43a-802a-465a-ad80-599eb9c22425
z: 1
b2182bd6-b01e-40d4-ac47-c02c16ea70e1:
source:
id: dda1f1d3-6048-4ae3-baa3-131166ed4911
target:
id: 82bd9f90-89db-4bd4-8cac-bbff00f0abe8
z: 1