forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
snapshot-optimize.yml
305 lines (280 loc) · 7.9 KB
/
snapshot-optimize.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 无代理ECS备份高效环境搭建
en: Deploy high-performance MySQL services based on EBS ESSD.
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:
- Priority: 1
PortRange: '-1/-1'
NicType: intranet
SourceCidrIp: 0.0.0.0/0
IpProtocol: all
VpcId:
Ref: VPC
SecurityGroupEgress:
- Priority: 1
PortRange: '-1/-1'
DestCidrIp: 0.0.0.0/0
NicType: intranet
IpProtocol: all
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
SnaptshotPolicy:
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:
- SnaptshotPolicy
- 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'