forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
existing-vpc-cluster-yarn.yml
1495 lines (1482 loc) · 58.3 KB
/
existing-vpc-cluster-yarn.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 is used to create multiple ECS instances based on an existing
VPC, vSwitch, and security group to deploy a Hadoop Yarn cluster. The ECS instance
that is assigned an EIP is the management node. Auto Scaling manages the remaining
ECS instances. Java JDK version 1.8.0 and Hadoop version 2.7.7 are used. To log
on to the Yarn console, you must configure the inbound rule that allows traffic
over port 8088. To log on to the HDFS console, you must configure the inbound
rule that allows traffic over port 50070.
zh-cn: 在已有虚拟专有网络、交换机和安全组基础资源上,创建多台ECS(Hadoop YARN),其中一台绑定弹性IP作为管理节点,其他节点使用弹性伸缩进行管理;Java
jdk版本是1.8.0,Hadoop版本是2.7.7,访问YARN管理界面需要安全组配置8088端口入规则,访问HDFS管理界面需要安全组配置50070端口入规则。
Parameters:
VpcId:
Type: String
Label:
en: Existing VPC Instance ID
zh-cn: 现有VPC的实例ID
Description:
en: Please search the ID starting with (vpc-xxx)from console-Virtual Private
Cloud
zh-cn: 控制台-VPC-专有网络下查询
AssociationProperty: ALIYUN::ECS::VPC::VPCId
VSwitchZoneId:
Type: String
Label:
en: VSwitch Zone ID
zh-cn: 交换机可用区
Description:
en: New Switch Availability Zone ID
zh-cn: 新建交换机Switch的可用区ID
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
VSwitchId:
Type: String
Label:
en: VSwitch ID
zh-cn: 网络交换机ID
Description:
en: Please search the business VSwitch ID starting with(vsw-xxx)from console-Virtual
Private Cloud-VSwitches
zh-cn: 现有业务网络交换机的实例ID,控制台-VPC-专有网络-交换机下查询
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: VpcId
SecurityGroupId:
Type: String
Label:
en: Business Security Group ID
zh-cn: 业务安全组ID
Description:
en: Please search the business security group ID starting with(sg-xxx)from console-ECS-Network
& Security
zh-cn: 现有业务安全组的实例ID,控制台-ECS-网络与安全-安全组下查询
AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
AssociationPropertyMetadata:
VpcId: VpcId
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例规格
Description:
en: <font color='blue'><b>1.Before selecting the model please confirm that the
current available zone under the model is in stock, some models need to be
reported in advance</b></font>]<br><font color='blue'><b>2.List of optional
models</font>]<br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB
Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPSS</font>]<br></b>[ecs.c5.xlarge
<font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and
receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU
16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
zh-cn: <font color='blue'><b>1.选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备</b></font><br><font
color='blue'><b>2.可选机型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU
4GiB 内网带宽1Gbps 内网收发包30万PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU
8GiB 内网带宽1.5Gbps 内网收发包50万PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU
16GiB 内网带宽2.5Gbps 内网收发包80万PPS</font>]
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: VSwitchZoneId
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,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
BindWidth:
Type: Number
Label:
en: Public IP Bandwidth
zh-cn: 公网IP带宽值
Description:
en: 'Public network IP bandwidth,unit: Mbps'
zh-cn: 公网IP带宽值,单位:Mbps
Default: 5
MinValue: 1
MaxValue: 100
DiskCategory:
Type: String
Label:
en: 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
DiskSize:
Type: Number
Label:
en: System Disk Space
zh-cn: 系统盘空间
Description:
en: ''
zh-cn: 实例系统盘大小,单位为GiB。取值范围:20~32768
Default: 40
MinValue: 20
MaxValue: 2048
Amount:
Type: Number
Label:
en: Instance Amount
zh-cn: 实例数量
Description:
en: 'ECS Instance Amount, Allowed value: 3~10'
zh-cn: 购买实例数量,允许值:3~10
Default: 3
MinValue: 3
MaxValue: 10
InstanceImageId:
Type: String
Label:
en: Image ID
zh-cn: 镜像ID
Description:
en: Image ID,See detail:<b><a href='https://www.alibabacloud.com/help/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
Resources:
RamRole:
Type: ALIYUN::RAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service:
- oos.aliyuncs.com
Version: '1'
Policies:
- PolicyDocument:
Statement:
- Action:
- ecs:*
Effect: Allow
Resource:
- '*'
- Action:
- vpc:DescribeVpcs
- vpc:DescribeVSwitches
Effect: Allow
Resource:
- '*'
- Action:
- ess:CompleteLifecycleAction
Effect: Allow
Resource:
- '*'
Version: '1'
PolicyName:
Fn::Join:
- ''
- - ros-StackId-
- Ref: ALIYUN::StackId
RoleName:
Fn::Join:
- ''
- - ros-StackId-
- Ref: ALIYUN::StackId
Metadata:
ALIYUN::ROS::Designer:
id: c40eb24b-0042-4ad8-b85c-b6155fa52238
OOSTemplateIn:
Type: ALIYUN::OOS::Template
Properties:
Content:
Fn::Join:
- ''
- - '{"FormatVersion": "OOS-2019-06-01","Parameters": {"regionId": {"Type":
"String","Default": "'
- Ref: ALIYUN::Region
- '"},"instanceIds": {"Type": "List","Default": ["${instanceId}"]},"lifecycleHookId":
{"Type": "String","Default": "${lifecycleHookId}"},"lifecycleActionToken":
{"Type": "String","Default": "${lifecycleActionToken}"}},"RamRole": "'
- Fn::GetAtt:
- RamRole
- RoleName
- '","Tasks": [{"Name": "runCommand","Action": "ACS::ECS::RunCommand","OnError":
"CompleteLifecycleActionForAbandon","OnSuccess": "CompleteLifecycleActionForContinue","Properties":
{"regionId": "{{ regionId }}","commandContent": "'
- 'cd /software && bash rm_node.sh '
- Ref: Amount
- ' && sleep 60'
- '","instanceId": "{{ ACS::TaskLoopItem }}","commandType": "RunShellScript"},
"Loop": {"RateControl": {"Mode":"Concurrency","MaxErrors":0,"Concurrency":10},"Items":
"{{ instanceIds }}","Outputs": {"commandOutputs": {"AggregateType": "Fn::ListJoin","AggregateField":
"commandOutput"}}},"Outputs": {"commandOutput": {"Type": "String","ValueSelector":
"invocationOutput"}}}, {"Name": "CompleteLifecycleActionForContinue","Action":
"ACS::ExecuteAPI","OnSuccess": "ACS::END","Properties": {"Service": "ESS","API":
"CompleteLifecycleAction","Parameters": {"RegionId": "{{ regionId }}","LifecycleHookId":
"{{ lifecycleHookId }}","LifecycleActionToken": "{{ lifecycleActionToken
}}"}}}, {"Name": "CompleteLifecycleActionForAbandon","Action": "ACS::ExecuteAPI","Properties":
{"Service": "ESS","API": "CompleteLifecycleAction","Parameters": {"RegionId":
"{{ regionId }}","LifecycleHookId": "{{ lifecycleHookId }}","LifecycleActionToken":
"{{ lifecycleActionToken }}","LifecycleActionResult": "ABANDON"}}}]}'
TemplateName:
Fn::Join:
- ''
- - ros-StackId-
- Ref: ALIYUN::StackId
DependsOn:
- RamRole
Metadata:
ALIYUN::ROS::Designer:
id: f38f57e5-4fad-404f-9550-45331dca1d60
EcsInstanceGroupMaster:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: VSwitchZoneId
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
SecurityGroupId:
Ref: SecurityGroupId
ImageId:
Ref: InstanceImageId
AllocatePublicIP: false
HostName:
Fn::Join:
- ''
- - YARN
- -[0,3]
InstanceChargeType: PostPaid
InstanceName:
Fn::Join:
- ''
- - YARN
- -[0,3]
InstanceType:
Ref: InstanceType
InternetMaxBandwidthIn:
Ref: BindWidth
InternetMaxBandwidthOut:
Ref: BindWidth
IoOptimized: optimized
MaxAmount: 1
Password:
Ref: InstancePassword
SystemDiskCategory:
Ref: DiskCategory
UserData:
Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionMasterHandle
- CurlCli
- Fn::Join:
- ''
- - "#!/bin/sh \n"
- PASSWORD="
- Ref: InstancePassword
- "\" \n"
- NODE_COUNT=
- Ref: Amount
- " \n"
- ROS_NOTIFY="
- Fn::GetAtt:
- RosWaitConditionClusterHandle
- CurlCli
- "\" \n"
- "sleep 10 \n"
- "set -e \n"
- "OSS_NAME=\"ros-template-resources\" \n"
- "OSS_REGION=\"cn-beijing\" \n"
- "ENDPOINT=\".aliyuncs.com\" \n"
- "OOS_JDK_FOLDER=\"JDK\" \n"
- "JDK_RPM=\"jdk-8u251-linux-i586.rpm\" \n"
- "OOS_HADOOP_FOLDER=\"Hadoop\" \n"
- "HADOOP_PACKAGE=\"hadoop-2.7.7.tar.gz\" \n"
- "ENV_DIR=\"/software\" \n"
- "BASH_PATH=\"/etc/profile\" \n"
- "RESOURCE_DIR=\"${ENV_DIR}/resources\" \n"
- "HADOOP_HOME=\"${ENV_DIR}/hadoop\" \n"
- "HOST_IP=$(ifconfig eth0 | awk '/inet /{print $2}') \n"
- "HOST_NAME=$(hostname) \n"
- "SSH_SCRIPT_FILE=\"${ENV_DIR}/ssh.sh\" \n"
- "NODES_INFO_FILE=\"${ENV_DIR}/nodes_info.ini\" \n"
- "CLUSTER_FILE=\"${ENV_DIR}/cluster.sh\" \n"
- "RM_NODES=\"${ENV_DIR}/rm_nodes.ini\" \n"
- "rm -rf /etc/hosts && touch /etc/hosts \n"
- " \n"
- "recordLog() { \n"
- " time=$(date \"+%Y-%m-%d %H:%M:%S\") \n"
- " echo \"$time --- $1\" >>\"${ENV_DIR}/userdata.log\" \n"
- "} \n"
- " \n"
- "createDir() { \n"
- " dir=$1 \n"
- " if [ -d \"${dir}\" ]; then \n"
- " recordLog \"Create failed, dir-${dir} is existed\" \n"
- " else \n"
- " mkdir -p \"${dir}\" \n"
- " recordLog \"Create Dir-${dir} successful\" \n"
- " fi \n"
- "} \n"
- " \n"
- "delete() { \n"
- " rm -rf \"$1\" && recordLog \"Remove path-$1 successful\" \n"
- "} \n"
- " \n"
- "download() { \n"
- " createDir ${RESOURCE_DIR} \n"
- " wget https://${OSS_NAME}.oss-${OSS_REGION}${ENDPOINT}/${OOS_JDK_FOLDER}/${JDK_RPM}\
\ -P ${RESOURCE_DIR} \n"
- " wget https://${OSS_NAME}.oss-${OSS_REGION}${ENDPOINT}/${OOS_HADOOP_FOLDER}/${HADOOP_PACKAGE}\
\ -P ${RESOURCE_DIR} \n"
- " recordLog \"Download resources successful\" \n"
- "} \n"
- " \n"
- "generateScript() { \n"
- " ssh-keygen -t rsa -P '' -f '/root/.ssh/id_rsa' \n"
- " yum -y install expect \n"
- " echo '#!/bin/bash' >${SSH_SCRIPT_FILE} \n"
- " echo 'name_or_ip=$1' >>${SSH_SCRIPT_FILE} \n"
- " echo 'authorized_key=$2' >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect <<EOF' >>${SSH_SCRIPT_FILE} \n"
- " echo 'set timeout 150' >>${SSH_SCRIPT_FILE} \n"
- " echo \"spawn ssh root@\\${name_or_ip} echo \\\"\\${authorized_key}\\\
\" >> /root/.ssh/authorized_keys\" >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect {' >>${SSH_SCRIPT_FILE} \n"
- " echo \" \\\"*yes/no*\\\" { send \\\"yes\\n\\\"; exp_continue }\"\
\ >>${SSH_SCRIPT_FILE} \n"
- " echo \" \\\"*password:\\\" { send \\\"${PASSWORD}\\n\\\" }\" >>${SSH_SCRIPT_FILE}\
\ \n"
- " echo '}' >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect eof' >>${SSH_SCRIPT_FILE} \n"
- " echo 'EOF' >>${SSH_SCRIPT_FILE} \n"
- " chmod +x ${SSH_SCRIPT_FILE} \n"
- " recordLog \"Generate ${SSH_SCRIPT_FILE} successful\" \n"
- " echo '#!/bin/bash' >\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'host_ip=$1' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'expect <<EOF' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'set timeout 150' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo \"spawn ssh root@\\${host_ip} exit;\" >>\"${SSH_SCRIPT_FILE}.login\"\
\ \n"
- " echo 'expect {' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo \" \\\"*yes/no*\\\" { send \\\"yes\\n\\\" }\" >>\"${SSH_SCRIPT_FILE}.login\"\
\ \n"
- " echo '}' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'expect eof' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'EOF' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " chmod +x \"${SSH_SCRIPT_FILE}.login\" \n"
- " recordLog \"Generate ${SSH_SCRIPT_FILE}.login successful\" \n"
- "} \n"
- " \n"
- "configSSH() { \n"
- " authorized_key=$(cat /root/.ssh/id_rsa.pub) \n"
- " bash ${SSH_SCRIPT_FILE} \"${HOST_IP}\" \"${authorized_key}\" \n"
- " bash \"${SSH_SCRIPT_FILE}.login\" \"0.0.0.0\" \n"
- " bash \"${SSH_SCRIPT_FILE}.login\" \"localhost\" \n"
- " recordLog \"Config expect-localhost successful\" \n"
- "} \n"
- " \n"
- "installJavaAndConfig() { \n"
- " yum -y install glibc.i686 \n"
- " cd ${RESOURCE_DIR} || exit && rpm -Uvh ${JDK_RPM} \n"
- " JAVA_HOME=$(find / -name jdk1.8.0_*) \n"
- " echo \"export JAVA_HOME=${JAVA_HOME}\" >>${BASH_PATH} \n"
- " echo \"export JRE_HOME=${JAVA_HOME}/jre\" >>${BASH_PATH} \n"
- " echo \"export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib\"\
\ >>${BASH_PATH} \n"
- " echo \"export PATH=${JAVA_HOME}/bin:$PATH\" >>${BASH_PATH} \n"
- " source ${BASH_PATH} \n"
- " cd ~ || exit \n"
- " recordLog \"Install and config java env successful\" \n"
- " # delete \"${RESOURCE_DIR}\\${JDK_RPM}\" #do not delete \n"
- "} \n"
- " \n"
- "installAndConfigHadoop() { \n"
- " cd ${RESOURCE_DIR} || exit && tar -zxvf \"${HADOOP_PACKAGE}\" -C\
\ ${ENV_DIR} && cd ${ENV_DIR} && mv hadoop-2.7.7 hadoop \n"
- " echo \"export HADOOP_HOME=${HADOOP_HOME}\" >>${BASH_PATH} \n"
- " echo \"export PATH=${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:$PATH\"\
\ >>${BASH_PATH} \n"
- " source ${BASH_PATH} \n"
- " sed -i 's/export JAVA_HOME=/#export JAVA_HOME=/' ${HADOOP_HOME}/etc/hadoop/hadoop-env.sh\
\ \n"
- " sed -i \"/#export JAVA_HOME=/a export JAVA_HOME=${JAVA_HOME}\"\
\ ${HADOOP_HOME}/etc/hadoop/hadoop-env.sh \n"
- " cd ${HADOOP_HOME}/etc/hadoop/ || recordLog \"Enter hadoop\\etc\\\
hadoop failed\" \n"
- " # config core-site.xml \n"
- ' cat >core-site.xml <<EOF
'
- "<configuration> \n"
- " <property> \n"
- " <name>fs.defaultFS</name> \n"
- " <value>hdfs://HOST_NAME:9000</value> \n"
- " <description>HDFS URI</description> \n"
- " </property> \n"
- " <property> \n"
- " <name>hadoop.tmp.dir</name> \n"
- " <value>TMP_DIR</value> \n"
- " <description>NameNode upload hadoop temp folder</description> \n"
- " </property> \n"
- " <property> \n"
- " <name>fs.checkpoint.period</name> \n"
- " <value>3600</value> \n"
- " <description>set backup log timeout</description> \n"
- " </property> \n"
- "</configuration> \n"
- 'EOF
'
- " sed -i \"s/HOST_NAME/${HOST_NAME}/\" core-site.xml \n"
- " sed -i \"s#TMP_DIR#${ENV_DIR}/tmp#\" core-site.xml \n"
- " recordLog \"Config core-site.xml successful\" \n"
- " # config hdfs-site.xml \n"
- ' cat >hdfs-site.xml <<EOF
'
- "<configuration> \n"
- " <property> \n"
- " <name>dfs.replication</name> \n"
- " <value>NODE_COUNT</value> \n"
- " <description>Duplication count</description> \n"
- " </property> \n"
- " <property> \n"
- " <name>dfs.name.dir</name> \n"
- " <value>HADOOP_HOME/hdfs/name</value> \n"
- " <description>DataNode name space metadata dir</description> \n"
- " </property> \n"
- " <property> \n"
- " <name>dfs.data.dir</name> \n"
- " <value>HADOOP_HOME/hdfs/data</value> \n"
- " <description>DataNode data dir location</description> \n"
- " </property> \n"
- "</configuration> \n"
- 'EOF
'
- " sed -i \"s#HADOOP_HOME#${HADOOP_HOME}#\" ${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " recordLog \"Config hdfs-site.xml successful\" \n"
- " # config yarn-site.xml \n"
- ' cat >yarn-site.xml <<EOF
'
- "<configuration> \n"
- " <property> \n"
- " <name>yarn.resourcemanager.hostname</name> \n"
- " <value>HOST_NAME</value> \n"
- " </property> \n"
- " <property> \n"
- " <name>yarn.nodemanager.aux-services</name> \n"
- " <value>mapreduce_shuffle</value> \n"
- " </property> \n"
- "</configuration> \n"
- 'EOF
'
- " sed -i \"s#HOST_NAME#${HOST_NAME}#\" ${ENV_DIR}/hadoop/etc/hadoop/yarn-site.xml\
\ \n"
- " recordLog \"Config yarn-site.xml successful\" \n"
- " mv ${ENV_DIR}/hadoop/etc/hadoop/slaves ${ENV_DIR}/hadoop/etc/hadoop/bak.slaves\
\ \n"
- " touch ${ENV_DIR}/hadoop/etc/hadoop/slaves \n"
- " recordLog \"Remove slave config default config\" \n"
- " delete \"${RESOURCE_DIR}/${HADOOP_PACKAGE}\" \n"
- "} \n"
- " \n"
- "generateClusterScript() { \n"
- ' cat >${CLUSTER_FILE} <<EOF
'
- "#!/bin/sh \n"
- "NODE_COUNT=\\$1 \n"
- "HOSTS_PATH=\"/etc/hosts\" \n"
- "ENV_DIR=\"/software\" \n"
- "SSH_SCRIPT_FILE=\"\\${ENV_DIR}/ssh.sh\" \n"
- "NODES_COUNT_FILE=\"\\${ENV_DIR}/nodes_count.ini\" \n"
- "HOST_IP=`ifconfig eth0 | awk '/inet /{print \\$2}'` \n"
- "NODES_INFO_FILE=\"\\${ENV_DIR}/nodes_info.ini\" \n"
- "RM_NODES=\"\\${ENV_DIR}/rm_nodes.ini\" \n"
- "OLD_NODE_COUNT=\"\\${ENV_DIR}/rm_nodes.ini\" \n"
- " \n"
- "configCluster() { \n"
- " rm -f \\${ENV_DIR}/hadoop/etc/hadoop/slaves \n"
- " yes|cp \\${HOSTS_PATH} \"\\${HOSTS_PATH}.bak\" \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " echo \"\\${node_hostname}\" >> \\${ENV_DIR}/hadoop/etc/hadoop/slaves\
\ \n"
- " if [ -d \"\\${ENV_DIR}/hadoop.bak\" ]; then \n"
- " yes|cp \"\\${ENV_DIR}/hadoop/etc/hadoop/slaves\" \"\\${ENV_DIR}/hadoop.bak/etc/hadoop/slaves\"\
\ \n"
- " fi \n"
- " old_node_count=0 \n"
- " if [ \\${NODE_COUNT} -ge \\${old_node_count} ]; then \n"
- " grep \"\\${node_hostname}\" \"\\${HOSTS_PATH}.bak\" \n"
- " if [ \\$? -ne \"0\" ] ;then \n"
- " echo \"\\${node_ip} \\${node_hostname}\" >>\\${HOSTS_PATH}\
\ \n"
- " authorized_key=\\$(cat /root/.ssh/id_rsa.pub) \n"
- " bash \\${SSH_SCRIPT_FILE} \"\\${node_hostname}\" \"\
\\${authorized_key}\" \n"
- " fi \n"
- " fi \n"
- " done \n"
- " \n"
- " if [ -f \\${NODES_COUNT_FILE} ]; then \n"
- " old_node_count=\\$(cat \\${NODES_COUNT_FILE}) \n"
- " sed -i \"s/\\${old_node_count}/\\${NODE_COUNT}/\" \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " sed -i \"s/\\${old_node_count}/\\${NODE_COUNT}/\" \\${ENV_DIR}/hadoop.bak/etc/hadoop/hdfs-site.xml\
\ \n"
- " if [ \\${NODE_COUNT} -gt \\${old_node_count} ]; then \n"
- " echo \"add\" \n"
- " if [ ! -f \"\\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts\"\
\ ] ;then \n"
- " sed -i \"\\|</configuration>|d\" \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <property>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <name>dfs.hosts</name>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <value>\\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts</value>\"\
\ >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml \n"
- " echo \" </property>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \"</configuration>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " fi \n"
- " rm -f \\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts \n"
- " yes|cp \\${ENV_DIR}/hadoop/etc/hadoop/slaves \\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts\
\ \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " scp \\${HOSTS_PATH} root@\\${node_hostname}:/etc/ \n"
- " grep \"\\${node_hostname}\" \"\\${HOSTS_PATH}.bak\"\
\ \n"
- " if [ \\$? -ne \"0\" ] ;then \n"
- " scp -r \\${ENV_DIR}/hadoop.bak root@\\${node_hostname}:\\\
${ENV_DIR}/hadoop \n"
- " fi \n"
- " done \n"
- " else \n"
- " echo \"remove\" \n"
- " if [ ! -f \"\\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts.exclude\"\
\ ] ;then \n"
- " sed -i \"\\|</configuration>|d\" \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <property>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <name>dfs.hosts.exclude</name>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \" <value>\\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts.exclude</value>\"\
\ >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml \n"
- " echo \" </property>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " echo \"</configuration>\" >> \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " fi \n"
- " mv \\${RM_NODES} \\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts.exclude\
\ \n"
- " if [ -f \"\\${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts\" ];\
\ then \n"
- " rm_nodes_info=\\$(cat \\${RM_NODES}) \n"
- " for rm_node_info in \\${rm_nodes_info[@]}; do \n"
- " sed -i '/\\${rm_node_info}/d' ${ENV_DIR}/hadoop/etc/hadoop/dfs.hosts\
\ \n"
- " done \n"
- " fi \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " scp \\${ENV_DIR}/hadoop.bak/etc/hadoop/hdfs-site.xml\
\ root@\\${node_hostname}:\\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " done \n"
- " fi \n"
- " else \n"
- " sed -i \"s/NODE_COUNT/\\${NODE_COUNT}/\" \\${ENV_DIR}/hadoop/etc/hadoop/hdfs-site.xml\
\ \n"
- " cp -rf \\${ENV_DIR}/hadoop /software/hadoop.bak \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " if [ \\${node_ip} -eq \\${HOST_IP} ]; then \n"
- " continue \n"
- " fi \n"
- " sleep 1 \n"
- " scp \\${HOSTS_PATH} root@\\${node_hostname}:/etc/ \n"
- " scp -r \\${ENV_DIR}/hadoop.bak root@\\${node_hostname}:\\\
${ENV_DIR}/hadoop \n"
- " done \n"
- " fi \n"
- "} \n"
- " \n"
- "startCluster() { \n"
- " if [ -f \\${NODES_COUNT_FILE} ]; then \n"
- " old_node_count=\\$(cat \\${NODES_COUNT_FILE}) \n"
- " if [ \\${NODE_COUNT} -gt \\${old_node_count} ]; then \n"
- " cd \\${ENV_DIR}/hadoop && bin/hdfs dfsadmin -refreshNodes\
\ \n"
- " bin/yarn rmadmin -refreshNodes && sbin/stop-yarn.sh &&\
\ sbin/start-yarn.sh \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " grep \"\\${node_hostname}\" \"\\${HOSTS_PATH}.bak\"\
\ \n"
- " if [ \\$? -ne \"0\" ] ;then \n"
- " echo \\$node_hostname \n"
- " ssh root@\\${node_hostname} \"cd \\${ENV_DIR}/hadoop\
\ && sbin/hadoop-daemon.sh start datanode && sbin/yarn-daemon.sh start\
\ nodemanager && exit;\" \n"
- " fi \n"
- " done \n"
- " cd \\${ENV_DIR}/hadoop && sbin/start-balancer.sh \n"
- " else \n"
- " echo \"remove\" \n"
- " cd \\${ENV_DIR}/hadoop && bin/hdfs dfsadmin -refreshNodes\
\ && bin/yarn rmadmin -refreshNodes \n"
- " sleep 5 \n"
- " rm_nodes_info=\\$(cat \\${RM_NODES}) \n"
- " for rm_node in \\${rm_nodes_info[@]}; do \n"
- " ssh root@\\${rm_node} \"cd \\${ENV_DIR}/hadoop && sbin/hadoop-daemon.sh\
\ stop datanode && sbin/yarn-daemon.sh stop nodemanager; sleep 5; exit;\"\
\ \n"
- " done \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " rm -f \\${HOSTS_PATH} \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " echo \"\\${node_ip} \\${node_hostname}\" >>\\${HOSTS_PATH}\
\ \n"
- " echo \"\\${node_ip} \\${node_hostname}\" \n"
- " scp -r \"\\${HOSTS_PATH}\" \\${node_hostname}:/etc\
\ \n"
- " done \n"
- " for node_info in \\${nodes_info[@]}; do \n"
- " new_node_info=(\\${node_info//:/ }) \n"
- " node_ip=\\${new_node_info[0]} \n"
- " node_hostname=\\${new_node_info[1]} \n"
- " scp -r \"\\${HOSTS_PATH}\" \\${node_hostname}:/etc\
\ \n"
- " done \n"
- " sleep 10 \n"
- " cd \\${ENV_DIR}/hadoop/ && sbin/stop-dfs.sh && sbin/stop-yarn.sh\
\ \n"
- " sbin/start-dfs.sh && bin/hdfs dfsadmin -refreshNodes \n"
- " sbin/start-yarn.sh && bin/yarn rmadmin -refreshNodes \n"
- " sbin/start-balancer.sh \n"
- " fi \n"
- " else \n"
- " cd \\${ENV_DIR}/hadoop/ && bin/hadoop namenode -format && sbin/start-dfs.sh\
\ \n"
- " sbin/start-yarn.sh \n"
- " fi \n"
- " echo \\${NODE_COUNT} >\\${NODES_COUNT_FILE} \n"
- "} \n"
- " \n"
- "main() { \n"
- " nodes_count=\\$(cat \\${NODES_INFO_FILE} | wc -l) \n"
- " nodes_info=\\$(cat \\${NODES_INFO_FILE}) \n"
- " if [ \\${nodes_count} -eq \\${NODE_COUNT} ]; then \n"
- " configCluster \n"
- " startCluster \n"
- " $ROS_NOTIFY \n"
- " fi \n"
- "} \n"
- " \n"
- "main \n"
- 'EOF
'
- "} \n"
- " \n"
- "main() { \n"
- " download \n"
- " generateScript \n"
- " configSSH \n"
- " installJavaAndConfig \n"
- " installAndConfigHadoop \n"
- " generateClusterScript \n"
- " echo \"${HOST_IP}:${HOST_NAME}\" >>${NODES_INFO_FILE} \n"
- " if [ -f ${RM_NODES} ]; then \n"
- " rm -f ${RM_NODES} \n"
- " fi \n"
- " touch ${RM_NODES} \n"
- "} \n"
- " \n"
- "main \n"
- "ros-notify -d \"{\\\"Status\\\" : \\\"Success\\\"}\" \n"
DependsOn:
- OOSTemplateIn
Metadata:
ALIYUN::ROS::Designer:
id: 4d17593b-029a-45bf-849a-38376b2ac955
VpcEip:
Type: ALIYUN::VPC::EIP
Properties:
Bandwidth:
Ref: BindWidth
InternetChargeType: PayByTraffic
Metadata:
ALIYUN::ROS::Designer:
id: c97c38d5-253b-4d8d-89f0-1537687b31b8
EipAssociation:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroupMaster
- InstanceIds
AllocationId:
Ref: VpcEip
DependsOn:
- VpcEip
Metadata:
ALIYUN::ROS::Designer:
id: fabc6711-b5c0-4aef-a1fc-fae3761b74a8
OOSTemplateOut:
Type: ALIYUN::OOS::Template
Properties:
Content:
Fn::Join:
- ''
- - "FormatVersion: OOS-2019-06-01\nParameters:\n regionId:\n Type: String\n\
\ Default: "
- Ref: ALIYUN::Region
- "\n instanceIds:\n Type: List\n Default:\n - '${instanceId}'\n\
\ lifecycleHookId:\n Type: String\n Default: '${lifecycleHookId}'\n\
\ lifecycleActionToken:\n Type: String\n Default: '${lifecycleActionToken}'\n\
RamRole: "
- Fn::GetAtt:
- RamRole
- RoleName
- "\nTasks:\n - Name: runCommand\n Action: 'ACS::ECS::RunCommand'\n\
\ OnError: CompleteLifecycleActionForAbandon\n OnSuccess: CompleteLifecycleActionForContinue\n\
\ Properties:\n regionId: '{{ regionId }}'\n commandContent:\
\ |- \n"
- Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionHandleEss
- CurlCli
- Fn::Join:
- ''
- - " #!/bin/sh \n"
- " hostname=$(hostname) \n"
- ' MASTER_IP='
- Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroupMaster
- PrivateIps
- '
'
- ' INSTANCE_PASSWORD='
- Ref: InstancePassword
- '
'
- " echo root:${INSTANCE_PASSWORD} | chpasswd \n"
- " # open sshd PasswordAuthentication \n"
- " sed -i 's/PasswordAuthentication no/PasswordAuthentication\
\ yes/g' \"/etc/ssh/sshd_config\" \n"
- " service sshd restart \n"
- ' PASSWORD="'
- Ref: InstancePassword
- "\" \n"
- ' NODE_COUNT='
- Ref: Amount
- '
'
- ' MASTER_HOSTNAME='
- Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroupMaster
- HostNames
- '
'
- " set -e \n"
- " JDK_RPM=\"jdk-8u251-linux-i586.rpm\" \n"
- " ENV_DIR=\"/software\" \n"
- " BASH_PATH=\"/etc/profile\" \n"
- " RESOURCE_DIR=\"${ENV_DIR}/resources\" \n"
- " HOST_IP=$(ifconfig eth0 | awk '/inet /{print $2}') \n"
- " HOST_NAME=$(hostname) \n"
- " SSH_SCRIPT_FILE=\"/root/ssh.sh\" \n"
- " NODES_INFO_FILE=\"${ENV_DIR}/nodes_info.ini\" \n"
- " NODES_COUNT_FILE=\"${ENV_DIR}/nodes_count.ini\" \n"
- " CLUSTER_FILE=\"${ENV_DIR}/cluster.sh\" \n"
- " RM_NODE_FILE=\"${ENV_DIR}/rm_node.sh\" \n"
- " ADD_NODE_FILE=\"${ENV_DIR}/add_node.sh\" \n"
- " RM_NODES=\"${ENV_DIR}/rm_nodes.ini\" \n"
- " \n"
- " recordLog() { \n"
- " time=$(date \"+%Y-%m-%d %H:%M:%S\") \n"
- " if [ ! -d ${ENV_DIR} ]; then \n"
- " mkdir ${ENV_DIR} \n"
- " fi \n"
- " echo \"$time --- $1\" >>\"${ENV_DIR}/userdata.log\"\
\ \n"
- " } \n"
- " \n"
- " generateScript() { \n"
- " ssh-keygen -t rsa -P '' -f '/root/.ssh/id_rsa' \n"
- " yum -y install expect \n"
- " echo '#!/bin/bash' >${SSH_SCRIPT_FILE} \n"
- " echo 'name_or_ip=$1' >>${SSH_SCRIPT_FILE} \n"
- " echo 'authorized_key=$2' >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect <<EOF' >>${SSH_SCRIPT_FILE} \n"
- " echo 'set timeout 150' >>${SSH_SCRIPT_FILE} \n"
- " echo \"spawn ssh root@\\${name_or_ip} echo \\\"\\${authorized_key}\\\
\" >> /root/.ssh/authorized_keys\" >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect {' >>${SSH_SCRIPT_FILE} \n"
- " echo \" \\\"*yes/no*\\\" { send \\\"yes\\n\\\"; exp_continue\
\ }\" >>${SSH_SCRIPT_FILE} \n"
- " echo \" \\\"*password:\\\" { send \\\"${PASSWORD}\\\
n\\\" }\" >>${SSH_SCRIPT_FILE} \n"
- " echo '}' >>${SSH_SCRIPT_FILE} \n"
- " echo 'expect eof' >>${SSH_SCRIPT_FILE} \n"
- " echo 'EOF' >>${SSH_SCRIPT_FILE} \n"
- " chmod +x ${SSH_SCRIPT_FILE} \n"
- " recordLog \"Generate ${SSH_SCRIPT_FILE} successful\"\
\ \n"
- " echo '#!/bin/bash' >\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'host_ip=$1' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'expect <<EOF' >>\"${SSH_SCRIPT_FILE}.login\"\
\ \n"
- " echo 'set timeout 150' >>\"${SSH_SCRIPT_FILE}.login\"\
\ \n"
- " echo \"spawn ssh root@\\${host_ip} exit;\" >>\"${SSH_SCRIPT_FILE}.login\"\
\ \n"
- " echo 'expect {' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo \" \\\"*yes/no*\\\" { send \\\"yes\\n\\\" }\"\
\ >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo '}' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'expect eof' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " echo 'EOF' >>\"${SSH_SCRIPT_FILE}.login\" \n"
- " chmod +x \"${SSH_SCRIPT_FILE}.login\" \n"
- " recordLog \"Generate ${SSH_SCRIPT_FILE}.login successful\"\
\ \n"
- " } \n"
- " \n"
- " configSSH() { \n"
- " authorized_key=$(cat /root/.ssh/id_rsa.pub) \n"
- " bash ${SSH_SCRIPT_FILE} \"${MASTER_IP}\" \"${authorized_key}\"\
\ \n"
- " bash ${SSH_SCRIPT_FILE} \"${HOST_IP}\" \"${authorized_key}\"\
\ \n"
- " bash \"${SSH_SCRIPT_FILE}.login\" \"0.0.0.0\" \n"
- " bash \"${SSH_SCRIPT_FILE}.login\" \"localhost\" \n"
- " sed -i \"s/${MASTER_IP}/${MASTER_HOSTNAME},${MASTER_IP}/\"\
\ \"/root/.ssh/known_hosts\" \n"
- " recordLog \"Config expect-localhost successful\" \n"
- " } \n"
- " \n"
- " installJavaAndConfig() { \n"
- " scp root@${MASTER_IP}:${RESOURCE_DIR}/${JDK_RPM} ./\
\ \n"
- " yum -y install glibc.i686 \n"
- " sleep 5 \n"
- " rpm -Uvh ${JDK_RPM} \n"
- " # config \n"
- " JAVA_HOME=$(find / -name jdk1.8.0_*) \n"
- " echo \"export JAVA_HOME=${JAVA_HOME}\" >>${BASH_PATH}\
\ \n"
- " echo \"export JRE_HOME=${JAVA_HOME}/jre\" >>${BASH_PATH}\
\ \n"
- " echo \"export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib\"\
\ >>${BASH_PATH} \n"
- " echo \"export PATH=${JAVA_HOME}/bin:$PATH\" >>${BASH_PATH}\
\ \n"
- " source ${BASH_PATH} \n"
- " recordLog \"Install and config java env successful\"\
\ \n"
- " rm -rf \"${JDK_RPM}\" \n"
- " recordLog \"Delete java rpm successful\" \n"
- " } \n"
- " \n"
- " configHadoop() { \n"
- " echo \"export HADOOP_HOME=${ENV_DIR}/hadoop\" >>${BASH_PATH}\
\ \n"
- " echo \"export PATH=${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:$PATH\"\
\ >>${BASH_PATH} \n"
- " source ${BASH_PATH} \n"
- " } \n"
- " \n"
- " generateAddNodeScript() { \n"
- " echo '#!/bin/bash' >${ADD_NODE_FILE} \n"
- " echo 'NODE_COUNT=$1' >>${ADD_NODE_FILE} \n"
- " echo \"ssh root@${MASTER_IP} \\\"echo '${HOST_IP}:${HOST_NAME}'\
\ >> ${NODES_INFO_FILE};bash ${CLUSTER_FILE} \\${NODE_COUNT} >>\
\ ${ENV_DIR}/userdata.log\\\"\" >>${ADD_NODE_FILE} \n"
- " echo \"ros-notify\" >> ${ADD_NODE_FILE} \n"
- " } \n"
- " \n"
- " generateRmNodeScript() { \n"
- " echo '#!/bin/bash' >${RM_NODE_FILE} \n"
- " echo 'NODE_COUNT=$1' >>${RM_NODE_FILE} \n"
- " echo \"ssh root@${MASTER_IP} \\\"sed -i '/${HOST_IP}:${HOST_NAME}/d'\
\ ${NODES_INFO_FILE} && echo \"${HOST_NAME}\" >> ${RM_NODES} &&\
\ bash ${CLUSTER_FILE} \\${NODE_COUNT} >> ${ENV_DIR}/userdata.log;\
\ exit;\\\"\" >>${RM_NODE_FILE} \n"
- " } \n"
- " \n"
- " main() { \n"
- " generateScript \n"
- " configSSH \n"
- " installJavaAndConfig \n"
- " configHadoop \n"
- " generateRmNodeScript \n"
- " generateAddNodeScript \n"
- " bash ${ADD_NODE_FILE} ${NODE_COUNT} \n"
- " } \n"
- " \n"
- " main \n"
- |2-
instanceId: '{{ ACS::TaskLoopItem }}'
commandType: RunShellScript
Loop:
RateControl:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
Items: '{{ instanceIds }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
OnSuccess: 'ACS::END'
Properties:
Service: ESS