Infiniband cluster Part 3

Useful Scripts

Intro:

This section contains the scripts I use to quickly redeploy the nodes. The “Post Script” could be improved a lot and also made more generic, however I’ll leave that as a task to the user, I may update it at some point if I have a need.

Kickstart Script:

Cluster Kickstart Script (557)

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
#Skip Install Key
key --skip
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard uk
# System language
lang en_GB
# Installation logging level
logging --level=info
# Use network installation
url --url=http://kickstart.example.com/x64/rhs53
# Reboot after installation
reboot
#Root password
#rootpw --iscrypted 

# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  Europe/London
# Install OS instead of upgrade
install
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=6144
part / --bytes-per-inode=4096 --fstype="ext3" --size=15360
part /tmp --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%post  --interpreter=/bin/bash
wget -O /tmp/bl1-cfg.sh http://kickstart.example.com/common/bl1-cfg.sh
chmod 744 /tmp/bl1-cfg.sh
sh /tmp/bl1-cfg.sh

%packages
@base
@server-cfg
@development-libs
@development-tools
@admin-tools
@system-tools
@legacy-software-development
@legacy-software-support
@editors
@openfabrics-enterprise-distribution
opensm

Post Script:

Cluster Post Script (591)

This script should be run on each node after the OS is installed. It is for a 16 node cluster so you may need to change some of the lines (MAC, IP, Domain, etc).

bl1-cfg.sh:


#!/bin/bash
##
#
#
#Get MAC address
MACA=`cat /sys/class/net/eth0/address | tr '[:lower:]' '[:upper:]'`;

#General Network Settings
echo 'DHCP_HOSTNAME=$HOSTNAME.example.com' >> /etc/sysconfig/network
sed -i 's/V6=yes/V6=no/' /etc/sysconfig/network
echo "NISDOMAIN=example" >> /etc/sysconfig/network
sed -i 's/=yes/=no/' /etc/sysconfig/network-scripts/ifcfg-eth0

#Setup VLAN
ifconfig eth0 up;
vconfig add eth0 2;
vconfig add eth0 3;

#Setup MainLAN VLAN
echo 'DEVICE=eth0.2' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2
echo 'BOOTPROTO=dhcp' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2
echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2
echo 'EERDNS=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2
echo 'PEERNTPD=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2
echo 'VLAN=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.2

#Allow pinging
echo '0' > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

#Setup RDCLUSTER VLAN
echo 'DEVICE=eth0.3' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
echo 'BOOTPROTO=none' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
#Set IP Address & hostname based on MAC
if [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.1' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-01/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.2' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-02/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.3' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-03/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.4' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-04/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.5' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-05/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.6' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-06/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.7' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-07/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.8' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-08/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.9' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-09/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.10' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-10/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.11' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-11/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.12' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-12/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.13' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-13/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.14' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-14/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.15' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-15/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
elif [ "$MACA" == "00:00:00:00:00:00" ]; then
 echo 'IPADDR=192.168.1.16' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
 sed -i 's/^HOSTNAME=localhost.localdomain/HOSTNAME=bl1-16/' /etc/sysconfig/network
 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
else
 echo 'ONBOOT=no' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
fi
echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3
echo 'VLAN=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0.3

#Setup hosts file
echo '192.168.1.1   bl1-01 bl1-01.example.com' >> /etc/hosts
echo '192.168.1.2   bl1-02 bl1-02.example.com' >> /etc/hosts
echo '192.168.1.3   bl1-03 bl1-03.example.com' >> /etc/hosts
echo '192.168.1.4   bl1-04 bl1-04.example.com' >> /etc/hosts
echo '192.168.1.5   bl1-05 bl1-05.example.com' >> /etc/hosts
echo '192.168.1.6   bl1-06 bl1-06.example.com' >> /etc/hosts
echo '192.168.1.7   bl1-07 bl1-07.example.com' >> /etc/hosts
echo '192.168.1.8   bl1-08 bl1-08.example.com' >> /etc/hosts
echo '192.168.1.9   bl1-09 bl1-09.example.com' >> /etc/hosts
echo '192.168.1.10  bl1-10 bl1-10.example.com' >> /etc/hosts
echo '192.168.1.11  bl1-11 bl1-11.example.com' >> /etc/hosts
echo '192.168.1.12  bl1-12 bl1-12.example.com' >> /etc/hosts
echo '192.168.1.13  bl1-13 bl1-13.example.com' >> /etc/hosts
echo '192.168.1.14  bl1-14 bl1-14.example.com' >> /etc/hosts
echo '192.168.1.15  bl1-15 bl1-15.example.com' >> /etc/hosts
echo '192.168.1.16  bl1-16 bl1-16.example.com' >> /etc/hosts

# Create a nodelist file (useful for scripts that touch all teh nodes
echo 'bl1-01' >> /etc/nodelist
echo 'bl1-02' >> /etc/nodelist
echo 'bl1-03' >> /etc/nodelist
echo 'bl1-04' >> /etc/nodelist
echo 'bl1-05' >> /etc/nodelist
echo 'bl1-06' >> /etc/nodelist
echo 'bl1-07' >> /etc/nodelist
echo 'bl1-08' >> /etc/nodelist
echo 'bl1-09' >> /etc/nodelist
echo 'bl1-10' >> /etc/nodelist
echo 'bl1-11' >> /etc/nodelist
echo 'bl1-12' >> /etc/nodelist
echo 'bl1-13' >> /etc/nodelist
echo 'bl1-14' >> /etc/nodelist
echo 'bl1-15' >> /etc/nodelist
echo 'bl1-16' >> /etc/nodelist

#Send mail saying finished
HNAME=`cat /etc/sysconfig/network | egrep ^HOSTNAME | cut -f2 -d"="`;
address=`ifconfig eth0.2 | grep 'inet addr'| awk '{print $2}'|sed -e "s/addr\://"`
mail -s "Kickstart complete for $address at $HNAME" it@example.com < /etc/redhat-release

Series Links

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.