|
Linux: "SUSE HA Installation" |
Dieses Script installiert unter SUSE Linux eine HA-Umgebung. Fehlende Softwarepakete werden nachinstalliert und für die Konfigurtaion notwendige Daten interaktiv abgefragt.
Einfach mit einen Unix Editor eine Shellscript-Datei erzeugen. Zum Beispiel "vi /usr/bin/local/install_ha.sh". Die Scriptcode reinkopieren und speichern. Jetzt nur noch die Datei mit "chmod -x /usr/bin/local/install_ha.sh" ausführbar machen. Die Datei kann jetzt mit root-Rechten /usr/bin/local/install_ha.sh ausgeführt werden. Die Aktion auf beiden Nodes durchführen und Fertig!
Haftungsausschluss beachten!
|
#!/bin/bash
# Spirithost, Februar 2010
clear
LOGFILE="/etc/ha.d/install_ha.log"
exec > >(tee $LOGFILE) 2>&1
set -e
HOST=`uname -n`
FQDN=`hostname -f`
cat <<EOF
Some helpful Informations before we start with the Installation:
----------------------------------------------------------------
1. Important: Please install first the secondary Cluster-Node
2. You can start the script also with the option "no-md5".
If you are using this option, the "authkeys"-file will be created alternative without openssl!
3. Old configuration files will be saved in the "/etc/ha.d/old_versions" directory.
4. Absence applications (heartbeat, openssl) will be installed automaticly if needed.
5. This script use only rudimentary spell check features.
6. The "Cluster-Node Name" have to match with the shell command "uname -n"!
7. You have to open the UDP-Port 694 if the Linux Firewall ist started!
EOF
echo -n "PRIMARY Cluster-Node Name (default=\"$HOST\"): ";read PNAME
[ -z $PNAME ] && PNAME=$HOST
echo -n "SECONDARY Cluster-Node Name (default=\"$HOST\"): ";read SNAME
[ -z $SNAME ] && SNAME=$HOST
[[ $PNAME = $SNAME ]] && echo "ERROR: Primary and Secondary Hostname are matching!" && exit 1
echo -n "Heartbeat Interfaces (default=\"eth1 eth0\"): ";read HEARTINT
[[ $HEARTINT = "" ]] && HEARTINT="eth1 eth0"
echo -n "SERVICE FQDN-Hostname for the Cluster: ";read SERVNAME
[ -z $SERVNAME ] && SERVNAME="ERROR: SERVICE FQDN-Hostname not set!"
echo -n "SERVICE IP-Adress for the Cluster: ";read SERVIP
[ -z $SERVIP ] && SERVIP="ERROR: SERVICE IP-Adress not set!"
echo -n "Names of the daemons located in \"/etc/rc.d/\" which are managed by HA (example: \"apache nagios\"): ";read SERVDAEMON
[[ $SERVDAEMON = "" ]] && SERVDAEMON="ERROR: DEAMONS not set!"
echo -n "Do you want to use \"ipfail\", then please insert one or more Hostnames or IP-Adresses: ";read PINGCHECK
[[ $PINGCHECK != "" ]] && PINGCHECKON="respawn hacluster "`find /usr/ -name "ipfail"`
[[ $PINGCHECK != "" ]] && PINGCHECKVAL="ping $PINGCHECK"
clear
echo
echo "SUMMARY:"
echo "--------"
echo "PRIMARY Cluster-Node: "$PNAME
echo "SECONDARY Cluster-Node: "$SNAME
echo "Heartbeat Interfaces: "$HEARTINT
echo "SERVICE FQDN-Hostname: "$SERVNAME
echo "SERVICE IP-Adress: "$SERVIP
echo "Names of managed daemons: "$SERVDAEMON
echo "----------------------------------------------------"
echo "Feature \"ipfail\" aktivated? No value means disabled: "$PINGCHECK
echo "----------------------------------------------------"
echo "Installation of the Feature \"csync\" is also recommended."
echo "Please visit also our Website www.spirithost.de for the install script"
echo
echo -n "Anything correct, then type \"yes\": ";read YES
[ ! "$YES" = "yes" ] && exit 0
# ++++++++++++++++++++++++++++ HA Installation ++++++++++++++++++++++++++++
if [ ! -f /etc/init.d/heartbeat ]; then
zypper update
zypper install heartbeat
else
echo "Heartbeat is already installed!"
mkdir -p /etc/ha.d/old_versions
[[ -e /etc/ha.d/ha.cf ]] && cp /etc/ha.d/ha.cf /etc/ha.d/old_versions/ha.cf.`date +%s`
[[ -e /etc/ha.d/authkeys ]] && cp /etc/ha.d/authkeys /etc/ha.d/old_versions/authkeys.`date +%s`
[[ -e /etc/ha.d/haresources ]] && cp /etc/ha.d/haresources /etc/ha.d/old_versions/haresources.`date +%s`
fi
cat <<EOF > /etc/ha.d/ha.cf
# File created with 'install_suse_ha' at `date`
node $PNAME
node $SNAME
#options: bcast, mcast, ucast, (serial)
udpport 694
bcast $HEARTINT
initdead 120
keepalive 5
warntime 30
deadtime 60
auto_failback on
crm off
use_logd yes
$PINGCHECKON
$PINGCHECKVAL
EOF
chmod 644 /etc/ha.d/ha.cf
cat <<EOF > /etc/ha.d/haresources
# File created with 'install_suse_ha.sh' at `date`
# The FQDN-Hostnamer the IP-Adress \"$SERVI\" is \"$SERNAME\".
$PNAME $SERVIP $SERVDAEMON
EOF
chmod 644 /etc/ha.d/haresources
if [[ $1 = "no-md5" ]]; then
cat <<EOF > /etc/ha.d/authkeys
# File created with 'install_suse_ha.sh' at `date`
1 sha1 sH`date +%m%Y`itS
EOF
[[ -f /etc/ha.d/authkeys ]] && chmod 400 /etc/ha.d/authkeys
else
if [[ $PNAME = $HOST ]]; then
echo 'Primary Cluster Node --> "authkeys"-file will be created'
[[ `which openssl` ]] || zypper install openssl
( echo -ne "auth 1\n1 sha1 "; dd if=/dev/urandom bs=512 count=1 | openssl md5 ) > /etc/ha.d/authkeys
[[ -f /etc/ha.d/authkeys ]] && chmod 400 /etc/ha.d/authkeys
echo ""
echo "Please insert the passwort for root. The secondary Host will be updated:"
exec `find /usr/ -name 'ha_propagate'`
fi
fi
exit
|
|