Linux HA 3
Aus HC Services
Inhaltsverzeichnis |
Linux HA 3 mit Centos 5.5
Installation
- Repository einbinden
rpm -Uvh http://download.fedora.redhat.com/pub/epel/<version>/<arch>/epel-release-<version>.noarch.rpm wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo
- Pakete installieren
yum install pacemaker heartbeat
Konfiguration
Cluster Knoten konfigurieren
- /etc/ha.d/ha.cf
Wichtig: die Knotennamen müssen exakt dem 'uname -n' entsprechen
autojoin none mcast bond0 239.0.0.1 694 1 0 bcast eth2 warntime 5 deadtime 15 initdead 60 keepalive 2 node centoscl1.daheim.local node centoscl2.daheim.local pacemaker respawn
- /etc/ha.d/authkeys
# Konfig und Crypt-String anlegen (echo -ne "auth 1\n1 sha1 "; dd if=/dev/urandom bs=512 count=1 | openssl md5) > /etc/ha.d/authkeys chmod 600 /etc/ha.d/authkeys
Clusterkonfiguration ausrollen
- SSH Keys anlegen
ssh-keygen ... cat .ssh/id_rsa.pub > .ssh/authorized_keys scp -rp .ssh centoscl2.daheim.local:
- /usr/share/heartbeat/ha_propagate patchen
--- /usr/share/heartbeat/ha_propagate 2011-02-19 12:21:53.000000000 +0100 +++ /usr/share/heartbeat/ha_propagate 2011-02-19 14:25:14.000000000 +0100 @@ -40,5 +40,5 @@ print "Propagating HA configuration files to node " + v + "." res = os.system("scp " + cfgfile + " " + authfile + " root@" + v + ":" + cfgdir) print "Setting HA startup configuration on node " + v + "." - res = os.system("ssh " + " root@" + v + " chkconfig `chkconfig heartbeat`") + res = os.system("ssh " + " root@" + v + " chkconfig heartbeat --add")
Cluster starten
/stc/init.d/heartbeat start
Funtionsprüfung
- ps -AHfww | grep heartbeat
root 4442 4130 0 14:35 pts/0 00:00:00 grep heartbeat root 4354 1 0 14:27 ? 00:00:00 heartbeat: master control process root 4357 4354 0 14:27 ? 00:00:00 heartbeat: FIFO reader root 4358 4354 0 14:27 ? 00:00:00 heartbeat: write: mcast eth0 root 4359 4354 0 14:27 ? 00:00:00 heartbeat: read: mcast eth0 root 4360 4354 0 14:27 ? 00:00:00 heartbeat: write: bcast eth0 root 4361 4354 0 14:27 ? 00:00:00 heartbeat: read: bcast eth0 498 4414 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/ccm 498 4415 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/cib root 4416 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/lrmd -r root 4417 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/stonithd 498 4418 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/attrd 498 4419 4354 0 14:28 ? 00:00:00 /usr/lib64/heartbeat/crmd
- crm_mon -1
============ Last updated: Sat Feb 19 14:35:37 2011 Stack: Heartbeat Current DC: centoscl2.daheim.local (4ccd8ea3-d9ae-4ab4-87c2-76831f1b46df) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, unknown expected votes 0 Resources configured. ============ Online: [ centoscl1.daheim.local centoscl2.daheim.local ]
Vorbereitung
- Stonith abschalten (wird in diesem Beispiel nicht zwingend benötigt)
crm configure property stonith-enabled=false
- Stickiness erhöhen um ein switchen intakter Ressourcen zu verhindern
crm configure rsc_defaults resource-stickiness=100
Vorbereitungen (alle Knoten)
- zentrales Verzeichnis anlegen
mkdir /web
- iSCSI Initiator auf manuell umstellen
/etc/iscsi/iscsid.conf
node.startup = manual
- iscsid restarten
- apache installieren
yum install apache
- DocumentRoot auf /web umstellen
/etc/httpd/conf/httpd.conf
DocumentRoot /web
- Apache server-status einschalten
/etc/httpd/conf/httpd.conf
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location>
Ressourcen anlegen
- Ressource IP Adresse erstellen
crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 params ip=<ip-adresse> cidr_netmask=32 op monitor interval=30s
- Ressource iSCSI Disk erstellen
crm configure primitive iSCSIDisk ocf:heartbeat:iscsi params target="<name>:<disk>" portal="<server-ip>" op monitor interval="30s"
- Ressource Mountpoint erstellen
iscsi-disk ist /dev/sdb1 und vorher mit xfs formatiert
crm configure primitive WebFS ocf:heartbeat:Filesystem params device="/dev/sdb1" directory="/web" fstype="xfs" op monitor interval="30s"
- Ressource httpd anlegen
crm configure primitive WebSite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1"30s"
Ressourcengruppe und Abhängigkeiten erstellen
- Ressourcen zusammenfassen
crm configure colocation website-with-ip-and-fs INFINITY: WebSite ClusterIP WebFS iSCSIDisk
- Reihenfolge festlegen
- Cluster IP
- iSCSI Disk
- Mountpoint
- Apache
crm configure order apache-after-ip-fs mandatory: ClusterIP iSCSIDisk WebFS WebSite
- bevorzugten Knoten festlegen
crm configure location prefer-centoscl1 WebSite 50: centoscl1.daheim.local
Zusammenfassung
Wenn alles gut gegangen ist kann man die Konfiguration folgendermaßen aufrufen:
- crm configure show
node $id="4ccd8ea3-d9ae-4ab4-87c2-76831f1b46df" centoscl2.daheim.local node $id="fc9c9033-f513-404f-83d1-ccc04b900725" centoscl1.daheim.local primitive ClusterIP ocf:heartbeat:IPaddr2 \ params ip="10.0.0.111" cidr_netmask="32" \ op monitor interval="30s" \ meta target-role="Started" primitive WebFS ocf:heartbeat:Filesystem \ params device="/dev/sdb1" directory="/web" fstype="xfs" \ op monitor interval="30s" \ meta target-role="Started" primitive WebSite ocf:heartbeat:apache \ params configfile="/etc/httpd/conf/httpd.conf" \ op monitor interval="1min" \ meta target-role="Started" primitive iSCSIDisk ocf:heartbeat:iscsi \ params target="iqn.1994-04.org.netbsd.iscsi-target:target0" portal="10.0.0.252" \ op monitor interval="30s" \ meta target-role="Started" location cli-prefer-WebSite WebSite \ rule $id="cli-prefer-rule-WebSite" inf: #uname eq centoscl1.daheim.local location cli-prefer-iSCSIDisk iSCSIDisk \ rule $id="cli-prefer-rule-iSCSIDisk" inf: #uname eq centoscl1.daheim.local location prefer-centoscl1 WebSite 50: centoscl1.daheim.local colocation website-with-ip-and-fs inf: WebSite ClusterIP WebFS iSCSIDisk order apache-after-ip-fs inf: ClusterIP iSCSIDisk WebFS WebSite property $id="cib-bootstrap-options" \ dc-version="1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3" \ cluster-infrastructure="Heartbeat" \ stonith-enabled="false" \ no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \ resource-stickiness="100"
- crm_mon -1
============ Last updated: Mon Feb 21 11:31:25 2011 Stack: Heartbeat Current DC: centoscl2.daheim.local (4ccd8ea3-d9ae-4ab4-87c2-76831f1b46df) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, unknown expected votes 4 Resources configured. ============ Online: [ centoscl1.daheim.local centoscl2.daheim.local ] ClusterIP (ocf::heartbeat:IPaddr2): Started centoscl1.daheim.local WebSite (ocf::heartbeat:apache): Started centoscl1.daheim.local WebFS (ocf::heartbeat:Filesystem): Started centoscl1.daheim.local iSCSIDisk (ocf::heartbeat:iscsi): Started centoscl1.daheim.local
Ressourcen managen
- Ressource starten
crm resource start <name>
- Ressource stoppen
crm resource stop <name>
- ressource auf einen anderen Knoten verschieben
crm resource move <name> <knoten-name> (crm resource move WebSite centoscl1.daheim.local)
- Ressource löschen
crm resource delete <name>
STONITH konfigurieren
STONITH (Shoot the other node in the head) ist ein Dienst, der in Kraft tritt, wenn der Heartbeat eines Knotens verloren geht, dieser Knoten aber u U. noch Zugriff auf die Daten hat. In diesem Fall wäre Datenverlust die Folge. Stonith versucht dann den über andere Wege wie z.B. IPMI, ILOM, oder VMWare Management, diesen Knoten zu isolieren (fencing).
Im folgenden Beispiel wird versucht, den Knoten per SSH runterzufahren. In der Praxis ist dies leider weniger sinnvoll, weil man, wenn ein Knoten nicht mehr antwortet, sicher auch keine SSH Verbindung mehr machen kann. Leider gab is in meiner Testumgebung keine bessere Möglichkeit und die Einbindung eines Managementboardes ist aus Sicht es Clusters absolut identisch.
- Anzeigen der verfügbaren Stonith Funktionen
stonith -L apcmaster apcmastersnmp apcsmart baytech bladehpi cyclades external/drac5 external/dracmc-telnet external/hmchttp external/ibmrsa external/ibmrsa-telnet external/ipmi external/ippower9258 external/kdumpcheck external/rackpdu external/riloe external/sbd external/ssh external/vmware external/xen0 external/xen0-ha ibmhmc ipmilan meatware null nw_rpc100s rcd_serial rps10 ssh suicide wti_mpc wti_nps
Wir verwenden external/ssh
- Anzeigen der Verfügbaren Parameter
stonith -t external/ssh -n hostlist
- Anlegen einer einzelnen Resource mit allen Knoten in "hostlist" (Wichtig: ssh via private key ohne Passphrase notwendig)
crm configure primitive stonith_via_ssh stonith::external/ssh params hostlist="centoscl1.daheim.local,centoscl2.daheim.local" op monitor interval="20s"
- Clonen der Resource um sie auf allen Knoten zu aktivieren
crm configure clone Fencing stonith_via_ssh
- STONITH (wieder) einschalten
crm configure property stonith-enabled="true"
- Konfiguration anschauen
crm configure show node $id="4ccd8ea3-d9ae-4ab4-87c2-76831f1b46df" centoscl2.daheim.local node $id="fc9c9033-f513-404f-83d1-ccc04b900725" centoscl1.daheim.local primitive ClusterIP ocf:heartbeat:IPaddr2 \ params ip="10.0.0.111" cidr_netmask="32" \ op monitor interval="30s" \ meta target-role="Started" primitive WebFS ocf:heartbeat:Filesystem \ params device="/dev/sdb1" directory="/web" fstype="xfs" \ op monitor interval="30s" \ meta target-role="Started" primitive WebSite ocf:heartbeat:apache \ params configfile="/etc/httpd/conf/httpd.conf" \ op monitor interval="1min" \ meta target-role="Started" primitive iSCSIDisk ocf:heartbeat:iscsi \ params target="iqn.1994-04.org.netbsd.iscsi-target:target0" portal="10.0.0.252" \ op monitor interval="30s" \ meta target-role="Started" primitive stonith_via_ssh stonith:external/ssh \ params hostlist="centoscl1.daheim.local,centoscl2.daheim.local" \ op monitor interval="20s" clone Fencing stonith_via_ssh location cli-prefer-WebSite WebSite \ rule $id="cli-prefer-rule-WebSite" inf: #uname eq centoscl1.daheim.local location cli-prefer-iSCSIDisk iSCSIDisk \ rule $id="cli-prefer-rule-iSCSIDisk" inf: #uname eq centoscl1.daheim.local location prefer-centoscl1 WebSite 50: centoscl1.daheim.local colocation website-with-ip-and-fs inf: WebSite ClusterIP WebFS iSCSIDisk order apache-after-ip-fs inf: ClusterIP iSCSIDisk WebFS WebSite property $id="cib-bootstrap-options" \ dc-version="1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3" \ cluster-infrastructure="Heartbeat" \ stonith-enabled="true" \ no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \ resource-stickiness="100"
- Prüfen on die Ressource "Fencing" auf allen Knoten aktiv ist
crm_mon -1 ... Clone Set: Fencing Started: [ centoscl2.daheim.local centoscl1.daheim.local ] ...