-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall_head_node.sh
More file actions
executable file
·1541 lines (1189 loc) · 53.3 KB
/
Copy pathinstall_head_node.sh
File metadata and controls
executable file
·1541 lines (1189 loc) · 53.3 KB
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
#!/bin/bash
################################################################################
######################## Microway Cluster Management Software (MCMS) for OpenHPC
################################################################################
#
# Copyright (c) 2015-2016 by Microway, Inc.
#
# This file is part of Microway Cluster Management Software (MCMS) for OpenHPC.
#
# MCMS for OpenHPC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MCMS for OpenHPC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MCMS. If not, see <http://www.gnu.org/licenses/>
#
################################################################################
################################################################################
##
## This script is a recipe for setting up OpenHPC on CentOS 7.x Linux
##
## http://www.openhpc.community/
##
##
## This script should be run on the cluster's Head/Master Node - also referred
## to as the System Management Server (SMS). This script presumes that a Red Hat
## derivative (CentOS, SL, etc) has just been installed (with vanilla
## configuration). It builds a ready-to-run compute node image with optional
## support for InfiniBand, NVIDIA GPUs and Xeon Phi coprocessors.
##
##
## Please note that certain design/configuration choices are made by this script
## which may not be compatible with all sites. Efforts are made to maintain
## portability, but compatibility cannot be guaranteed.
##
################################################################################
################################################################################
# Determine where this script is running from (so we can locate patches, etc.)
################################################################################
install_script_dir="$( dirname "$( readlink -f "$0" )" )"
dependencies_dir=${install_script_dir}/dependencies
config_file=${install_script_dir}/configuration_settings.txt
# Ensure the settings have been completed
if [[ ! -r ${config_file} ]]; then
echo "
This script requires you to provide configuration settings. Please ensure
that the file ${config_file} exists and has been fully completed.
"
exit 1
else
source ${config_file}
fi
if [[ ! -z "$(egrep "^[^#].*ChangeMe" ${config_file})" ]]; then
echo "
For security, you *must* change the passwords in the configuration file.
Please double-check your settings in ${config_file}
"
exit 1
fi
################################################################################
# Currently, only RHEL/SL/CentOS 7 is supported for the bootstrap
################################################################################
distribution=$(egrep "CentOS Linux 7|Scientific Linux 7|Red Hat Enterprise Linux Server release 7" /etc/*-release)
centos_check=$?
if [[ ${centos_check} -ne 0 ]]; then
echo "
Currently, only RHEL, Scientific and CentOS Linux 7 are supported
"
exit 1
else
echo "RHEL/SL/CentOS 7 was detected. Continuing..."
fi
################################################################################
# Update system packages and EPEL package repo
################################################################################
yum -y update
yum -y install epel-release
################################################################################
# Install tools we'll need during the setup
################################################################################
yum -y install python-pip
################################################################################
# If enabled, disable auto-update on the Head Node.
# The compute nodes don't have yum installed.
################################################################################
if [[ -r /etc/sysconfig/yum-autoupdate ]]; then
sed -i 's/ENABLED="true"/ENABLED="false"/' /etc/sysconfig/yum-autoupdate
fi
################################################################################
# Disable SELinux
################################################################################
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
################################################################################
# Enable NTP (particularly important for things like SLURM and Ceph)
################################################################################
yum -y install ntp ntpdate ntp-doc
if [[ ! -z "${ntp_server}" ]]; then
sed -i 's/^server /#server /' /etc/ntp.conf
echo -e "
server ${ntp_server}
" >> /etc/ntp.conf
ntpdate ${ntp_server}
else
ntpdate 0.rhel.pool.ntp.org \
1.rhel.pool.ntp.org \
2.rhel.pool.ntp.org \
3.rhel.pool.ntp.org
fi
# Because some clusters are not connected to the Internet, we need to enable
# orphan mode as described here:
#
# https://www.eecis.udel.edu/~mills/ntp/html/miscopt.html#tos
#
echo "
tos orphan 5
" >> /etc/ntp.conf
hwclock --systohc --utc
systemctl enable ntpd.service
systemctl start ntpd.service
################################################################################
# Disable X-Windows since the Head Node is typically a headless server
################################################################################
systemctl set-default multi-user.target
################################################################################
# Add the OpenHPC repository and install the baseline OpenHPC packages
################################################################################
curl -L -o /tmp/ohpc-release.x86_64.rpm ${ohpc_repo}
yum -y install /tmp/ohpc-release.x86_64.rpm
rm -f /tmp/ohpc-release.x86_64.rpm
yum -y install docs-ohpc
yum -y groupinstall ohpc-base
yum -y groupinstall ohpc-warewulf
yum -y install warewulf-ipmi-ohpc warewulf-nhc-ohpc
# Create a group for HPC administrators
groupadd hpc-admin
################################################################################
# Install Genders (which associates roles with each system)
################################################################################
yum -y install genders-ohpc
install -p -o root -g root -m 644 ${dependencies_dir}/etc/genders /etc/genders
# Set up the default roles for the Head/SMS and Compute Node systems
echo -e "${sms_name}\thead,sms,login" >> /etc/genders
for ((i=0; i<$compute_node_count; i++)) ; do
c_name=${compute_node_name_prefix}$(( ${i} + 1 ))
echo -e "${c_name}\tcompute,bmc=${c_bmc[$i]}"
done >> /etc/genders
################################################################################
# Install ClusterShell (Python-based library for parallel command execution)
################################################################################
yum -y install clustershell-ohpc
# Set up node definitions
mv /etc/clustershell/groups.d/{local.cfg,local.cfg.orig}
echo "
adm: ${sms_name}
compute: ${compute_node_name_prefix}[1-${compute_node_count}]
all: @adm,@compute
" > /etc/clustershell/groups.d/local.cfg
################################################################################
# Add InfiniBand support
################################################################################
if [[ "${enable_infiniband}" == "true" ]]; then
yum -y groupinstall "InfiniBand Support"
yum -y install infiniband-diags perftest qperf opensm
echo "
# Allow user processes to pin more memory (required for InfiniBand/RDMA)
* soft memlock unlimited
* hard memlock unlimited
" > /etc/security/limits.d/rdma.conf
echo "
DEVICE=ib0
BOOTPROTO=static
IPADDR=${sms_ipoib}
NETMASK=${ipoib_netmask}
ONBOOT=yes
STARTMODE='auto'
" >> /etc/sysconfig/network-scripts/ifcfg-ib0
systemctl enable rdma.service
systemctl start rdma.service
systemctl enable opensm.service
systemctl start opensm.service
fi
################################################################################
# Configure the Head Node to be able to talk to Compute Node BMCs
# This assumes that the Compute Node BMCs are using their shared network port.
################################################################################
network_alias_file="/etc/sysconfig/network-scripts/ifcfg-${sms_eth_internal}:0"
cp /etc/sysconfig/network-scripts/ifcfg-${sms_eth_internal} ${network_alias_file}
sed -i "s/NM_CONTROLLED.*/NM_CONTROLLED=no/" ${network_alias_file}
sed -i "s/DEVICE.*/DEVICE=${sms_eth_internal}:0/" ${network_alias_file}
sed -i "s/${internal_subnet_prefix}/${bmc_subnet_prefix}/" ${network_alias_file}
sed -i "s/NETMASK.*/NETMASK=${bmc_netmask}/" ${network_alias_file}
################################################################################
# Configure the firewall
################################################################################
# Ensure the firewall is active (some VM images don't include it)
yum -y install firewalld
systemctl enable firewalld.service
systemctl start firewalld.service
# Allow all traffic on the internal cluster network interface
firewall-cmd --permanent --zone=trusted --change-interface=${sms_eth_internal}
# Perform NAT for traffic going out the public interface
firewall-cmd --permanent --zone=public --add-masquerade
sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/ip_forward.conf
# Be restrictive on the external network interface
firewall-cmd --permanent --zone=public --change-interface=${sms_eth_external}
# If there is an InfiniBand fabric, trust its traffic
if [[ "${enable_infiniband}" == "true" ]]; then
firewall-cmd --permanent --zone=trusted --change-interface=ib0
fi
# Reload rules for them to take effect
firewall-cmd --reload
################################################################################
# Configure and start the Warewulf services
################################################################################
sed -i "s/device = eth1/device = ${sms_eth_internal}/" /etc/warewulf/provision.conf
# Apache
export HTTPD_FILE=/etc/httpd/conf.d/warewulf-httpd.conf
sed -i -r "s/cgi-bin>\$/cgi-bin>\n Require all granted/" $HTTPD_FILE
sed -i "s/Allow from all/Require all granted/" $HTTPD_FILE
perl -ni -e "print unless /^\s+Order allow,deny/" $HTTPD_FILE
systemctl enable httpd.service
systemctl restart httpd.service
# TFTP
sed -i -r "s/^\s+disable\s+= yes/ disable = no/" /etc/xinetd.d/tftp
systemctl restart xinetd.service
# MariaDB Database
systemctl enable mariadb.service
systemctl restart mariadb.service
# NFS Exports
echo "
/home *(rw,no_subtree_check,fsid=10,no_root_squash)
/opt *(ro,no_subtree_check,fsid=11)
" >> /etc/exports
exportfs -a
# Enable the NFS services
systemctl enable rpcbind.service
systemctl enable nfs-server.service
# The following fixes may be needed:
#
# echo "
# [Install]
# WantedBy=multi-user.target
#
# " >> /usr/lib/systemd/system/nfs-idmap.service
# echo "
#
# [Install]
# WantedBy=nfs.target
#
# " >> /usr/lib/systemd/system/nfs-lock.service
systemctl enable nfs-lock.service
systemctl enable nfs-idmap.service
systemctl start rpcbind.service
systemctl start nfs-server.service
systemctl start nfs-lock.service
systemctl start nfs-idmap.service
systemctl restart nfs.service
################################################################################
# Set up Warewulf access to the SQL database
################################################################################
mysqladmin create warewulf
sed -i "s/database driver.*/database driver = mariadb/" /etc/warewulf/database.conf
sed -i "s/database user.*/database user = warewulf/" /etc/warewulf/database-root.conf
sed -i "s/database password.*/database password = ${db_mgmt_password}/" /etc/warewulf/database-root.conf
echo "GRANT ALL ON warewulf.* TO 'warewulf'@'localhost' IDENTIFIED BY '${db_mgmt_password}';" \
"GRANT ALL ON warewulf.* TO 'warewulf'@'$(hostname)' IDENTIFIED BY '${db_mgmt_password}';" \
"GRANT ALL ON warewulf.* TO 'warewulf'@'$(hostname -s)' IDENTIFIED BY '${db_mgmt_password}';" \
"FLUSH PRIVILEGES;" \
| mysql -u root
################################################################################
# Create the Compute Node image with OpenHPC in Warewulf
################################################################################
# Initialize the compute node chroot installation
export node_chroot_name=centos-7
export node_chroot=/opt/ohpc/admin/images/${node_chroot_name}
if [[ ! -z "${BOS_MIRROR}" ]]; then
sed -i -r "s#^YUM_MIRROR=(\S+)#YUM_MIRROR=${BOS_MIRROR}#" /usr/libexec/warewulf/wwmkchroot/centos-7.tmpl
fi
wwmkchroot ${node_chroot_name} ${node_chroot}
# Distribute root's SSH keys across the cluster
wwinit ssh_keys
cat ~/.ssh/cluster.pub >> ${node_chroot}/root/.ssh/authorized_keys
# Revoke SSH access to all compute nodes (except for root and admins)
if [[ "${restrict_user_ssh_logins}" == "true" ]]; then
yum -y --installroot=${node_chroot} install slurm-pam_slurm-ohpc
echo "
- : ALL EXCEPT root hpc-admin : ALL
" >> ${node_chroot}/etc/security/access.conf
echo "
# Check for entries in /etc/security/access.conf
account sufficient pam_access.so
# Reject users who do not have jobs running on this node
account required pam_slurm.so
" >> ${node_chroot}/etc/pam.d/sshd
fi
# Copy DNS resolution settings to the node installation
cp -p /etc/resolv.conf ${node_chroot}/etc/resolv.conf
# Install necessary compute node daemons
yum -y --installroot=${node_chroot} groupinstall ohpc-slurm-client
yum -y --installroot=${node_chroot} install kernel lmod-ohpc ntp
yum -y --installroot=${node_chroot} install freeipmi-ipmiseld
chroot ${node_chroot} systemctl enable munge.service
chroot ${node_chroot} systemctl enable slurm.service
chroot ${node_chroot} systemctl enable ipmiseld.service
# Install and configure Node Health Check (NHC)
yum -y --installroot=${node_chroot} install warewulf-nhc-ohpc
cp ${dependencies_dir}/etc/nhc/* ${node_chroot}/etc/nhc/
cp ${dependencies_dir}/etc/sysconfig/nhc ${node_chroot}/etc/sysconfig/
if [[ "${enable_infiniband}" == "true" ]]; then
yum -y --installroot=${node_chroot} groupinstall "InfiniBand Support"
echo "
# Allow user processes to pin more memory (required for InfiniBand/RDMA)
* soft memlock unlimited
* hard memlock unlimited
" > ${node_chroot}/etc/security/limits.d/rdma.conf
chroot ${node_chroot} systemctl enable rdma.service
fi
# Configure NTP
if [[ ! -z "${ntp_server}" ]]; then
sed -i 's/^server /#server /' ${node_chroot}/etc/ntp.conf
echo -e "
server ${ntp_server}
" >> ${node_chroot}/etc/ntp.conf
fi
echo "
# Because some clusters are not connected to the Internet, we need to enable
# orphan mode as described here:
#
# https://www.eecis.udel.edu/~mills/ntp/html/miscopt.html#tos
#
tos orphan 5
" >> ${node_chroot}/etc/ntp.conf
chroot ${node_chroot} systemctl enable ntpd.service
# NFS mounts
echo "
# NFS mounts from the Head Node
${sms_ip}:/home /home nfs nfsvers=3,rsize=1024,wsize=1024,cto 0 0
${sms_ip}:/opt/ohpc /opt/ohpc nfs nfsvers=3,ro 0 0
${sms_ip}:/opt/ohpc/admin/images/${node_chroot} /vnfs nfs nfsvers=3 0 0
" >> ${node_chroot}/etc/fstab
################################################################################
# Add to the stub for the /etc/hosts file
################################################################################
echo "
################################################################################
#
# WARNING: the values below were configured and set for your cluster. Changing
# these values after the fact can break the cluster - take care.
#
# Specific examples of changes which *will* break your cluster:
#
# * changing the name of any server listed in this file
# * more than one line for any particular host name (e.g., head)
# * more than one line for any one IP address (e.g., 127.0.0.1)
#
#
# Also take note that the cluster will automatically add additional entries as
# you add more compute nodes. In most cases, you do not need to edit this file.
#
################################################################################
" >> /etc/hosts
# Ensure that the Head Node's name is in /etc/hosts
egrep "^[^#]+$(hostname -s)" /etc/hosts
if [[ $? -ne 0 ]]; then
echo "
# Head Node of the cluster
${sms_ip} $(hostname -s) salt
" >> /etc/hosts
fi
################################################################################
# Install SaltStack, which provides distribution-agnostic configuration mgmt
################################################################################
yum -y install salt-minion salt-master
yum -y --installroot=${node_chroot} install salt-minion
systemctl enable salt-master
systemctl start salt-master
systemctl enable salt-minion
systemctl start salt-minion
chroot ${node_chroot} systemctl enable salt-minion
# Note that the minion keys will need to be accepted once the cluster is up:
# salt-key --accept-all
################################################################################
# Install SLURM
################################################################################
yum -y groupinstall ohpc-slurm-server
# Create a SLURM user and group (SLURM will run as this user)
useradd --system slurm --home-dir /var/spool/slurmd --no-create-home
# SLURM needs to be able to control nodes (e.g., power on/off)
usermod --append --groups warewulf slurm
# After installing SLURM, the configuration is vanilla. You can customize here:
#
# http://slurm.schedmd.com/configurator.html
#
install -p -o slurm -g slurm -m 644 ${dependencies_dir}/etc/slurm/slurm.conf /etc/slurm/slurm.conf
install -p -o slurm -g slurm -m 640 ${dependencies_dir}/etc/slurm/slurmdbd.conf /etc/slurm/slurmdbd.conf
# Customize the configuration files
sed -i "s/{clusterName}/${cluster_acct_hierarchy['cluster_name']}/" /etc/slurm/slurm.conf
sed -i "s/{headName}/$(hostname -s)/" /etc/slurm/slurm.conf
sed -i "s/StoragePass={ChangeMe}/StoragePass=${db_mgmt_password}/" /etc/slurm/slurmdbd.conf
# Setup cgroups
rm -f /etc/slurm/cgroup/*
cp -a /etc/slurm/cgroup.release_common.example /etc/slurm/cgroup/release_common
# The 'blkio' and 'cpuacct' subsystems are left out as they are only needed for
# the 'jobacct_gather/cgroup' job accounting statistics plugin. The cgroup
# plugin is reported to be slower than the 'jobacct_gather/linux' plugin.
for resource in cpuset freezer memory devices; do
ln -s /etc/slurm/cgroup/release_common /etc/slurm/cgroup/release_${resource}
done
cp -af /etc/slurm/cgroup ${node_chroot}/etc/slurm/
cp ${dependencies_dir}/etc/slurm/cgroup.conf /etc/slurm/
cp ${dependencies_dir}/etc/slurm/cgroup.conf ${node_chroot}/etc/slurm/
cp ${dependencies_dir}/etc/slurm/cgroup_allowed_devices_file.conf /etc/slurm/
cp ${dependencies_dir}/etc/slurm/cgroup_allowed_devices_file.conf ${node_chroot}/etc/slurm/
# Setup the plugin stack
cp ${dependencies_dir}/etc/slurm/plugstack.conf /etc/slurm/
cp ${dependencies_dir}/etc/slurm/plugstack.conf ${node_chroot}/etc/slurm/
mkdir -p /etc/slurm/plugstack.conf.d
cp ${dependencies_dir}/etc/slurm/plugstack.conf.d/x11.conf /etc/slurm/plugstack.conf.d/
cp -af /etc/slurm/plugstack.conf.d ${node_chroot}/etc/slurm/
# Put the prolog/epilog/healthcheck scripts in place
mkdir -p {,${node_chroot}}/etc/slurm/scripts
cp -a ${dependencies_dir}/etc/slurm/scripts/* /etc/slurm/scripts/
cp -a ${dependencies_dir}/etc/slurm/scripts/* ${node_chroot}/etc/slurm/scripts/
# Remove the simpler epilog script that comes with the distro
rm -f {,${node_chroot}}/etc/slurm/slurm.epilog.clean
# Set up SLURM log rotation
cp ${dependencies_dir}/etc/logrotate.d/slurm /etc/logrotate.d/
cp ${dependencies_dir}/etc/logrotate.d/slurm ${node_chroot}/etc/logrotate.d/
# Ensure the proper SLURM running state and log directories are in place
mkdir -p {,${node_chroot}}/var/{lib,run,spool}/slurmd
mkdir -p {,${node_chroot}}/var/log/slurm
chown slurm:slurm {,${node_chroot}}/var/{lib,run,spool}/slurmd
chown slurm:slurm {,${node_chroot}}/var/log/slurm
# Add some additional settings/capabilities during slurmd start-up
cp ${dependencies_dir}/etc/slurm/gres.conf /etc/slurm/
cp ${dependencies_dir}/etc/slurm/gres.conf ${node_chroot}/etc/slurm/
# Generate SSH key which allows slurm to spawn health checks on nodes
mkdir -p /var/spool/slurmd/.ssh/
chmod 700 /var/spool/slurmd/.ssh/
chown slurm:slurm /var/spool/slurmd/.ssh/
ssh-keygen -t rsa -N "" -f ${node_chroot}/root/.ssh/healthcheck-ssh-key \
-C "Allow SLURM to spawn health checks as root user on compute nodes"
mv ${node_chroot}/root/.ssh/healthcheck-ssh-key \
/var/spool/slurmd/.ssh/.healthcheck-ssh-key
cp -a ${node_chroot}/root/.ssh/healthcheck-ssh-key.pub \
/var/spool/slurmd/.ssh/.healthcheck-ssh-key.pub
chmod 600 /var/spool/slurmd/.ssh/.healthcheck-ssh-key
chown slurm:slurm /var/spool/slurmd/.ssh/.healthcheck-ssh-key \
/var/spool/slurmd/.ssh/.healthcheck-ssh-key.pub
# Modify the access key to only allow the execution of the health check
cat ${node_chroot}/root/.ssh/healthcheck-ssh-key.pub | sed 's+^+no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="/root/.ssh/validate-ssh-command" +' >> ${node_chroot}/root/.ssh/authorized_keys
# Ensure SSH will connect to new nodes
echo "# Require no strict host checking when logging into nodes as the slurm user
Host *
StrictHostKeyChecking=no" >> /var/spool/slurmd/.ssh/config
chmod 600 /var/spool/slurmd/.ssh/config
chown slurm:slurm /var/spool/slurmd/.ssh/config
# Generate SSH key which allows slurm to power down idle nodes
ssh-keygen -t rsa -N "" -f ${node_chroot}/root/.ssh/poweroff-ssh-key \
-C "Allow SLURM to power off compute nodes as the root user"
mv ${node_chroot}/root/.ssh/poweroff-ssh-key \
/var/spool/slurmd/.ssh/.poweroff-ssh-key
cp -a ${node_chroot}/root/.ssh/poweroff-ssh-key.pub \
/var/spool/slurmd/.ssh/.poweroff-ssh-key.pub
chmod 600 /var/spool/slurmd/.ssh/.poweroff-ssh-key
chown slurm:slurm /var/spool/slurmd/.ssh/.poweroff-ssh-key \
/var/spool/slurmd/.ssh/.poweroff-ssh-key.pub
# Modify the access key to only allow the execution of the power off on compute nodes
cat ${node_chroot}/root/.ssh/poweroff-ssh-key.pub | sed 's+^+no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="/root/.ssh/validate-ssh-command" +' >> ${node_chroot}/root/.ssh/authorized_keys
# Finalize SLURM's SSH key setup
cp -a ${dependencies_dir}/var/spool/slurmd/validate-ssh-command \
${node_chroot}/root/.ssh/validate-ssh-command
chmod 600 ${node_chroot}/root/.ssh/authorized_keys
# Set up SQL database for slurmdbd accounting
mysqladmin create slurm_acct_db
echo "GRANT ALL ON slurm_acct_db.* TO 'slurm'@'localhost' IDENTIFIED BY '${db_mgmt_password}';" \
"GRANT ALL ON slurm_acct_db.* TO 'slurm'@'$(hostname)' IDENTIFIED BY '${db_mgmt_password}';" \
"GRANT ALL ON slurm_acct_db.* TO 'slurm'@'$(hostname -s)' IDENTIFIED BY '${db_mgmt_password}';" \
"FLUSH PRIVILEGES;" \
| mysql -u root
# Start up the SLURM services on the Head Node
systemctl enable munge.service
systemctl start munge.service
systemctl enable slurmdbd.service
systemctl start slurmdbd.service
# Set up SLURM accounting information. You must define clusters before you add
# accounts, and you must add accounts before you can add users.
sacctmgr --immediate add cluster ${cluster_acct_hierarchy['cluster_name']}
sacctmgr --immediate add account ${cluster_acct_hierarchy['default_organization']} \
description="${cluster_acct_hierarchy['default_organization_description']}"
sacctmgr --immediate add account ${cluster_acct_hierarchy['default_account']} \
description="${cluster_acct_hierarchy['default_account_description']}" \
organization=${cluster_acct_hierarchy['default_organization']}
systemctl enable slurm.service
systemctl start slurm.service
################################################################################
# Secure the SQL database
################################################################################
echo "
y
${db_root_password}
${db_root_password}
y
y
y
y
" | mysql_secure_installation
################################################################################
# Ensure the PCI devices IDs are up to date
################################################################################
update-pciids
chroot ${node_chroot} update-pciids
################################################################################
# Syncronize the built-in users/groups between Head and Compute Nodes
#
# If not done now, the users created by the following packages will have
# different UIDs and GIDs on the Compute Nodes than on the Head Node.
################################################################################
cp -af /etc/passwd ${node_chroot}/etc/
cp -af /etc/group ${node_chroot}/etc/
################################################################################
# Install Ganglia on the Head Node and Compute Nodes
################################################################################
yum -y groupinstall ohpc-ganglia
yum -y --installroot=${node_chroot} install ganglia-gmond-ohpc
systemctl enable gmond.service
systemctl enable gmetad.service
systemctl start gmond.service
systemctl start gmetad.service
chroot ${node_chroot} systemctl enable gmond.service
for i in httpd apache2; do
if [ -d /etc/$i ]; then
sed -i "s/Require local/Require all granted/" /etc/$i/conf.d/ganglia-ohpc.conf
fi
done
systemctl try-restart httpd.service
################################################################################
# Install InfluxDB for metric storage
################################################################################
curl -L -o influxdb.rpm https://dl.influxdata.com/influxdb/releases/influxdb-0.12.2-1.x86_64.rpm
yum -y install influxdb.rpm
rm -f influxdb.rpm
# Turn on Influx's listener for Graphite/Carbon data
perl -0777 -i -pe 's/\[\[graphite\]\]\n enabled = false/[[graphite]]\n enabled = true/' /etc/influxdb/influxdb.conf
systemctl enable influxdb.service
systemctl start influxdb.service
################################################################################
# Install Performance Co-Pilot (PCP) for metric collection
################################################################################
yum -y install avahi pcp pcp-doc pcp-gui pcp-manager
systemctl enable pmcd.service
systemctl start pmcd.service
systemctl enable pmlogger.service
systemctl start pmlogger.service
# Configure PCP to monitor the Head Node
echo "${sms_name}" > /etc/pcp/pmmgr/target-host
# Configure PCP to discover all other systems/nodes on the internal network
internal_subnet=$(ip route | awk "/${sms_eth_internal}/ {print $1}")
echo "
avahi,timeout=2.5
probe=${internal_subnet}
" > /etc/pcp/pmmgr/target-discovery
systemctl enable pmmgr.service
systemctl start pmmgr.service
yum -y --installroot=${node_chroot} install pcp
chroot ${node_chroot} systemctl enable pmcd.service
chroot ${node_chroot} systemctl enable pmlogger.service
# Provide a web interface for the data
yum -y install pcp-webjs pcp-webapi
systemctl enable pmwebd.service
systemctl start pmwebd.service
################################################################################
# Install Elasticsearch for analytics on log/event data
################################################################################
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
echo "[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1" > /etc/yum.repos.d/elasticsearch.repo
yum -y install elasticsearch
# For security, limit connections to localhost
sed -i 's/# network.host.*/network.host: localhost/' /etc/elasticsearch/elasticsearch.yml
systemctl enable elasticsearch.service
systemctl start elasticsearch.service
################################################################################
# Install Kibana web interface to Elasticsearch
################################################################################
echo "[kibana-4.5]
name=Kibana repository for 4.5.x packages
baseurl=http://packages.elastic.co/kibana/4.5/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1" > /etc/yum.repos.d/kibana.repo
yum -y install kibana
systemctl enable kibana.service
systemctl start kibana.service
################################################################################
# Install LogStash for aggregation and parsing of cluster syslogs
################################################################################
echo "[logstash-2.3]
name=Logstash repository for 2.3.x packages
baseurl=https://packages.elastic.co/logstash/2.3/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1" > /etc/yum.repos.d/logstash.repo
yum -y install logstash
# Security certs are needed when transferring logs between systems
perl -0777 -pe "s/\[ v3_ca \]\n/[ v3_ca ]\n\nsubjectAltName = IP:${sms_ip}\n/" /etc/pki/tls/openssl.cnf
openssl req -config /etc/pki/tls/openssl.cnf \
-x509 -days 3650 -batch -nodes -newkey rsa:2048 \
-keyout /etc/pki/tls/private/logstash-forwarder.key \
-out /etc/pki/tls/certs/logstash-forwarder.crt
cp -a /etc/pki/tls/certs/logstash-forwarder.crt ${node_chroot}/etc/pki/tls/certs/
# Put the LogStash input and parsing configurations into place
cp -a ${dependencies_dir}/etc/logstash/conf.d/* /etc/logstash/conf.d/
# Put the IP-to-geolocation database into place
wget --tries=20 --waitretry=10 --retry-connrefused --output-document=- \
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | \
gunzip > /etc/logstash/GeoLiteCity.dat
systemctl enable logstash.service
systemctl start logstash.service
################################################################################
# Install FileBeat on Head Node and Compute Node (forwards syslogs to LogStash)
################################################################################
echo "[beats]
name=Elastic Beats Repository
baseurl=https://packages.elastic.co/beats/yum/el/\$basearch
enabled=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
gpgcheck=1" > /etc/yum.repos.d/elastic-beats.repo
cp -a /etc/yum.repos.d/elastic-beats.repo ${node_chroot}/etc/yum.repos.d/
yum -y install filebeat
yum -y --installroot=${node_chroot} install filebeat
# Put the FileBeat configuration into place
mv /etc/filebeat/filebeat.yml{,.orig}
mv ${node_chroot}/etc/filebeat/filebeat.yml{,.orig}
cp -a ${dependencies_dir}/etc/filebeat/filebeat.yml /etc/filebeat/
cp -a ${dependencies_dir}/etc/filebeat/filebeat.yml ${node_chroot}/etc/filebeat/
sed -i "s/{sms_ip}/${sms_ip}/" /etc/filebeat/filebeat.yml
sed -i "s/{sms_ip}/${sms_ip}/" ${node_chroot}/etc/filebeat/filebeat.yml
systemctl enable filebeat.service
systemctl start filebeat.service
chroot ${node_chroot} systemctl enable filebeat.service
################################################################################
# Install Intel Cluster Checker on the Head Node and Compute Nodes
################################################################################
yum -y install intel-clck-ohpc
yum -y --installroot=${node_chroot} install intel-clck-ohpc
################################################################################
# If desired, configure the Lustre parallel filesystem mount
################################################################################
if [ "${enable_lustre_client}" == "true" ];then
# Install Lustre client on master
yum -y install lustre-client-ohpc lustre-client-ohpc-modules
# Enable lustre in Compute Node image
yum -y --installroot=${node_chroot} install lustre-client-ohpc lustre-client-ohpc-modules
mkdir -p /mnt/lustre
mkdir -p ${node_chroot}/mnt/lustre
echo "
${mgs_fs_name} /mnt/lustre lustre defaults,_netdev,localflock 0 0
" >> /etc/fstab
echo "
${mgs_fs_name} /mnt/lustre lustre defaults,_netdev,localflock 0 0
" >> ${node_chroot}/etc/fstab
# Enable o2ib for Lustre
echo "options lnet networks=o2ib(ib0)" >> /etc/modprobe.d/lustre.conf
echo "options lnet networks=o2ib(ib0)" >> ${node_chroot}/etc/modprobe.d/lustre.conf
# Mount Lustre client on master
mount /mnt/lustre
fi
################################################################################
# Finish assembly of the basic Compute Node image
################################################################################
# Configure the nodes to use the provisioning interface for the gateway
echo "GATEWAYDEV=${eth_provision}" >> ${node_chroot}/etc/sysconfig/network
# Add XFS if it isn't there
sed -i 's/ext3, ext4$/ext2, ext3, ext4, xfs/' /etc/warewulf/bootstrap.conf
# Avoid confusion on the Mellanox driver options
sed -i 's/^# modprobe += mlx4_core .*//' /etc/warewulf/bootstrap.conf
# Add fix for Mellanox module settings and drivers which might be needed
echo "
# According to OpenMPI devs, Mellanox recommends that log_mtts_per_seg be set
# low (~1) and log_num_mtt be set high (24~27). A value of 24 allows for a 256GB
# virtual address space. A value of 27 provides 1024GB. Virtual space should be
# twice that of physical memory.
modprobe += mlx4_core log_num_mtt=25 log_mtts_per_seg=1, ib_srp
# Required to load Lustre client
drivers += updates/kernel/
" >> /etc/warewulf/bootstrap.conf
if [[ "${enable_phi_coprocessor}" == "true" ]]; then
echo "
# Driver and bridging capability for Intel(R) Xeon Phi(tm) coprocessors
drivers += extra/mic.ko
drivers += bridge
" >> /etc/warewulf/bootstrap.conf
fi
if [[ "${enable_nvidia_gpu}" == "true" ]]; then
echo "
# Required for NVIDIA GPUs
drivers += extra/nvidia.ko
drivers += extra/nvidia-uvm.ko
" >> /etc/warewulf/bootstrap.conf
fi
# Update the bootstrap image for the current Linux kernel version
echo yes | wwbootstrap `uname -r`
# Link the files which will be automatically synced to the nodes periodically
wwsh file import /etc/passwd
wwsh file import /etc/group
wwsh file import /etc/shadow
wwsh file import /etc/genders
wwsh file import /etc/slurm/slurm.conf
wwsh file import /etc/munge/munge.key
if [ "${enable_infiniband}" == "true" ];then
wwsh file import /opt/ohpc/pub/examples/network/centos/ifcfg-ib0.ww
wwsh -y file set ifcfg-ib0.ww --path=/etc/sysconfig/network-scripts/ifcfg-ib0
fi
# Assemble VNFS
wwvnfs -y --chroot ${node_chroot}
# Add the compute node hosts to the cluster
for ((i=0; i<$compute_node_count; i++)) ; do
c_name=${compute_node_name_prefix}$(( ${i} + 1 ))
wwsh -y node new ${c_name} --ipaddr=${c_ip[$i]} \
--netmask=${internal_netmask} \
--hwaddr=${c_mac[$i]} \
--netdev=${eth_provision} \
--mtu=9000 \
--gateway=${sms_ip}
wwsh -y ipmi set ${c_name} --autoconfig=1 \
--ipaddr=${c_bmc[$i]} \
--netmask=${bmc_netmask} \
--username="${bmc_username}" \
--password="${bmc_password}"
done
################################################################################
# If you need to scan for the new nodes (you don't know their MAC addresses)
################################################################################
#
# wwnodescan --netdev=${eth_provision} --ipaddr=${c_ip[0]} \
# --netmask=${internal_netmask} --vnfs=${node_chroot_name} \
# --bootstrap=`uname -r` \
# ${compute_node_name_prefix}0-${compute_node_name_prefix}3
# wwsh pxe update
#
# Configure all compute nodes to boot the same Linux image