-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathhadoop.yml
538 lines (524 loc) · 14.1 KB
/
hadoop.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 部署Hadoop环境。
en: Deploy the Hadoop environment.
Conditions:
CreateInstance:
Fn::Equals:
- Ref: InstanceSource
- CreateNew
UseExistedInstance:
Fn::Equals:
- Ref: InstanceSource
- UseExisted
Parameters:
InstanceSource:
Type: String
Label:
zh-cn: 实例来源
en: Instance Source
AssociationPropertyMetadata:
ValueLabelMapping:
CreateNew:
zh-cn: 创建新实例
en: Create New Instance
UseExisted:
zh-cn: 选择已有实例
en: Select Existed Instance
Default: CreateNew
AllowedValues:
- CreateNew
- UseExisted
ZoneId:
Type: String
Label:
en: Availability Zone
zh-cn: 可用区
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
AssociationPropertyMetadata:
AutoSelectFirst: true
Visible:
Condition:
Fn::Equals:
- ${InstanceSource}
- CreateNew
Default:
ImageId:
Type: String
Label:
en: Image of Instance
zh-cn: 实例镜像
AssociationPropertyMetadata:
ValueLabelMapping:
aliyun_3_x64_20G_alibase_20240528.vhd:
zh-cn: Alibaba Cloud Linux 3
en: Alibaba Cloud Linux 3
Visible:
Condition:
Fn::Equals:
- ${InstanceSource}
- CreateNew
Default: aliyun_3_x64_20G_alibase_20240528.vhd
AllowedValues:
- aliyun_3_x64_20G_alibase_20240528.vhd
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
SpotStrategy: SpotAsPriceGo
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
Visible:
Condition:
Fn::Equals:
- ${InstanceSource}
- CreateNew
Default:
InstancePassword:
Type: String
Label:
en: Instance 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,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${InstanceSource}
- CreateNew
Default:
NoEcho: true
Confirm: true
EcsInstanceId:
Type: String
Label:
en: ECS Instance ID
zh-cn: ECS实例ID
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
Status: Running
Visible:
Condition:
Fn::Equals:
- ${InstanceSource}
- UseExisted
Default:
CommonName:
Type: String
Default: deploy-hadoop-by-ros
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Condition: CreateInstance
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: ${CommonName}-vpc
VSwitch:
Type: 'ALIYUN::ECS::VSwitch'
Condition: CreateInstance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
VSwitchName:
Fn::Sub: ${CommonName}-vsw
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Condition: CreateInstance
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
SecurityGroupIngress:
- PortRange: 8088/8088
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 9870/9870
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: '-1/-1'
SourceCidrIp: 0.0.0.0/0
IpProtocol: icmp
EcsInstance:
Type: 'ALIYUN::ECS::InstanceGroup'
Condition: CreateInstance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId:
Ref: ImageId
InstanceName:
Fn::Sub: ${CommonName}-ecs
InstanceType:
Ref: InstanceType
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 100
SpotStrategy: SpotAsPriceGo
Password:
Ref: InstancePassword
DeployHadoop:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
- Fn::If:
- UseExistedInstance
- Ref: EcsInstanceId
- Ref: EcsInstance
Type: RunShellScript
Sync: true
Timeout: 3600
CommandContent:
Fn::Sub: |-
#!/bin/bash
if command -v java &> /dev/null; then
echo "当前环境已存在java,请选择创建一台新的ECS或者未安装Java的ECS进行部署。"
exit 0
fi
wget -c -t 10 https://download.java.net/openjdk/jdk8u41/ri/openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
tar -zxvf openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
sudo mv java-se-8u41-ri/ /usr/java8
sudo sh -c "echo 'export JAVA_HOME=/usr/java8' >> /etc/profile"
sudo sh -c 'echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile'
sudo source /etc/profile
sudo wget -c -t 10 https://mirrors.bfsu.edu.cn/apache/hadoop/common/hadoop-3.2.4/hadoop-3.2.4.tar.gz
sudo tar -zxvf hadoop-3.2.4.tar.gz -C /opt/
sudo mv /opt/hadoop-3.2.4 /opt/hadoop
sudo sh -c "echo 'export HADOOP_HOME=/opt/hadoop' >> /etc/profile"
sudo sh -c "echo 'export PATH=\$PATH:/opt/hadoop/bin' >> /etc/profile"
sudo sh -c "echo 'export PATH=\$PATH:/opt/hadoop/sbin' >> /etc/profile"
source /etc/profile
sudo sh -c 'echo "export JAVA_HOME=/usr/java8" >> /opt/hadoop/etc/hadoop/yarn-env.sh'
sudo sh -c 'echo "export JAVA_HOME=/usr/java8" >> /opt/hadoop/etc/hadoop/hadoop-env.sh'
sudo mv /opt/hadoop/etc/hadoop/core-site.xml /opt/hadoop/etc/hadoop/core-site.xml.bak
sudo cat > /opt/hadoop/etc/hadoop/core-site.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/opt/hadoop/tmp</value>
<description>location to store temporary files</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
EOF
sudo mv /opt/hadoop/etc/hadoop/hdfs-site.xml /opt/hadoop/etc/hadoop/hdfs-site.xml.bak
sudo cat > /opt/hadoop/etc/hadoop/hdfs-site.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/opt/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/opt/hadoop/tmp/dfs/data</value>
</property>
</configuration>
EOF
ssh-keygen -t rsa -N '' -q -f /root/.ssh/id_rsa
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
sed -i '32 a HDFS_DATANODE_USER=root' /opt/hadoop/sbin/start-dfs.sh
sed -i '32 a HADOOP_SECURE_DN_USER=hdfs' /opt/hadoop/sbin/start-dfs.sh
sed -i '32 a HDFS_NAMENODE_USER=root' /opt/hadoop/sbin/start-dfs.sh
sed -i '32 a HDFS_SECONDARYNAMENODE_USER=root' /opt/hadoop/sbin/start-dfs.sh
sed -i '20 a HDFS_DATANODE_USER=root' /opt/hadoop/sbin/stop-dfs.sh
sed -i '20 a HADOOP_SECURE_DN_USER=hdfs' /opt/hadoop/sbin/stop-dfs.sh
sed -i '20 a HDFS_NAMENODE_USER=root' /opt/hadoop/sbin/stop-dfs.sh
sed -i '20 a HDFS_SECONDARYNAMENODE_USER=root' /opt/hadoop/sbin/stop-dfs.sh
sed -i '16 a YARN_RESOURCEMANAGER_USER=root' /opt/hadoop/sbin/start-yarn.sh
sed -i '16 a HADOOP_SECURE_DN_USER=yarn' /opt/hadoop/sbin/start-yarn.sh
sed -i '16 a YARN_NODEMANAGER_USER=root' /opt/hadoop/sbin/start-yarn.sh
sed -i '16 a YARN_RESOURCEMANAGER_USER=root' /opt/hadoop/sbin/stop-yarn.sh
sed -i '16 a HADOOP_SECURE_DN_USER=yarn' /opt/hadoop/sbin/stop-yarn.sh
sed -i '16 a YARN_NODEMANAGER_USER=root' /opt/hadoop/sbin/stop-yarn.sh
hadoop namenode -format
start-dfs.sh
start-yarn.sh
DsEcs:
Type: 'DATASOURCE::ECS::Instances'
Properties:
InstanceIds:
- Fn::If:
- UseExistedInstance
- Ref: EcsInstanceId
- Ref: EcsInstance
SecurityGroupIngress_8088:
Type: ALIYUN::ECS::SecurityGroupIngress
Condition: UseExistedInstance
Properties:
SecurityGroupId:
Fn::Jq:
- First
- .[0].SecurityGroupIds[0]
- Fn::GetAtt:
- DsEcs
- Instances
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 8088/8088
SecurityGroupIngress_9870:
Type: ALIYUN::ECS::SecurityGroupIngress
Condition: UseExistedInstance
Properties:
SecurityGroupId:
Fn::Jq:
- First
- .[0].SecurityGroupIds[0]
- Fn::GetAtt:
- DsEcs
- Instances
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 9870/9870
Outputs:
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=${InstanceId}
- InstanceId:
Fn::If:
- UseExistedInstance
- Ref: EcsInstanceId
- Ref: EcsInstance
Console@Url:
Description:
en: YARN Web Address.
zh-cn: YARN 访问地址。
Value:
Fn::Sub:
- http://${PublicIp}:8088
- PublicIp:
Fn::Jq:
- First
- if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress
end
- Fn::GetAtt:
- DsEcs
- Instances
Hadoop NameNode Web Page:
Description:
en: Hadoop NameNode Web Address.
zh-cn: Hadoop NameNode 访问页面。
Value:
Fn::Sub:
- http://${PublicIp}:9870
- PublicIp:
Fn::Jq:
- First
- if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress
end
- Fn::GetAtt:
- DsEcs
- Instances
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- InstanceSource
- ZoneId
- ImageId
- InstanceType
- InstancePassword
- EcsInstanceId
TemplateTags:
- acs:document-help:ecs:部署Hadoop环境
Hidden:
- CommonName
ALIYUN::ROS::Composer:
b13d9e0e:
Rect:
- 689
- 569
- 157
- 145
- 1
- 0
ResT: Composer::ROSParameter::AlibabaCloud
Label: AlibabaCloud
7cd11a5e:
Parent: b13d9e0e
Rect:
- 622
- 445
- 190
- 226
- 2
- 0
ResT: Composer::ROSParameter::Region
Label: 华东2(上海)
29549ba7:
Res:
- Vpc
Parent: 7cd11a5e
Rect:
- 506
- 373
- 227
- 276
- 3
- 0
Label: 专有网络VPC
07afc1e7:
Res:
- DeployHadoop
Parent: 7cd11a5e
Rect:
- 40
- 40
- 418
- 200
- 3
- 0
Label: 执行云助手命令
89582cdb:
Res:
- SecurityGroupIngress_8088
Parent: 7cd11a5e
Rect:
- 40
- 40
- 566
- 200
- 3
- 0
Label: 安全组入规则
c55b7fa2:
Res:
- SecurityGroupIngress_9870
Parent: 7cd11a5e
Rect:
- 40
- 40
- 671
- 200
- 3
- 0
Label: 安全组入规则
9b8690d1:
Res:
- ZoneId
Parent: 29549ba7
Rect:
- 271
- 247
- 270
- 356
- 4
- 0
ResT: Composer::ROSParameter::Zone
Label: 可用区
6ba20b15:
Res:
- VSwitch
Parent: 9b8690d1
Rect:
- 241
- 199
- 280
- 384
- 5
- 0
Label: 交换机
bca14b6f:
Res:
- SecurityGroup
Parent: 29549ba7
Rect:
- 448
- 317
- 262
- 306
- 11
- 0
Label: 安全组
98f368ea:
Res:
- EcsInstance
Parent: 6ba20b15
Rect:
- 40
- 40
- 417
- 448
- 12
- 0
Layer:
- bca14b6f
Label: 云服务器实例组
20b489c9:
Parent: 29549ba7
Rect:
- 40
- 40
- 620
- 448
- 12
- 0
ResT: DATASOURCE::ECS::Instances
Label: ECS_Instances
a270fafc:
Parent: 7cd11a5e
Edge:
- 07afc1e7
- 98f368ea
Line: 0:0:0:gray:0
e5590fe1:
Parent: 29549ba7
Edge:
- 20b489c9
- 98f368ea
Line: 0:0:0:gray:0
f5d8b01c:
Parent: 7cd11a5e
Edge:
- 89582cdb
- 20b489c9
Line: 0:0:0:gray:0
7b273642:
Parent: 7cd11a5e
Edge:
- c55b7fa2
- 20b489c9
Line: 0:0:0:gray:0