For the sample configuration we will have two nodes called ha01 and ha02, and we will service an IP address, that we will call the Virtual IP address (VIP), on an active / passive configuration. Both nodes will need to have name resolution configured either through DNS or the /etc/hosts file.

Installing Pacemaker-Heartbeat

First of all, we need to add the repositories to be able to install heartbeat. We add the following to /etc/apt/sources.list

deb http://ppa.launchpad.net/ubuntu-ha/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/ubuntu-ha/ppa/ubuntu karmic main

Then, we issue the following:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B64F0AFA

Now, we can install pacemaker-heartbeat:

sudo apt-get update && sudo apt-get install pacemaker-heartbeat

Configuring

Pacemaker-Heartbeat needs 3 main configuration files. These are /etc/ha.d/authkeys, /etc/ha.d/ha.cf, and /var/lib/heartbeat/crm/cib.xml. There is a fourth configuration file, /etc/logd.cf, which contains the log settings.

auth 1
1 md5 DesiredPassword

sudo chmod 600 /etc/ha.d/authkeys

logfile /var/log/ha-log

or do as root

sed -e 's/#logfile*/logfile/' /usr/share/doc/heartbeat/logd.cf > /etc/logd.cf

use_logd on
udpport 694
keepalive 2
warntime 15
deadtime 30
initdead 30
mcast eth0 239.0.0.43 694 1 0
node ha01 ha02
crm respawn

scp /etc/ha.d/authkeys ha02:~
scp /etc/ha.d/ha.cf ha02:~
scp /etc/logd.cf ha02:~

sudo mv authkeys /etc/ha.d/
sudo mv ha.cf /etc/ha.d/
sudo mv logd.cf /etc/

sudo /etc/init.d/heartbeat start

crm_attribute --attr-name symmetric-cluster --attr-value true
crm_attribute --attr-name default-resource-stickiness --attr-value INFINITY
crm_attribute --attr-name stonith-enabled --attr-value false

        <group id="group_1">
         <primitive class="ocf" id="VIP_eth0" provider="heartbeat" type="IPaddr2">
           <operations>
             <op id="VIP_eth0_mon" interval="5s" name="monitor" timeout="5s"/>
           </operations>
           <instance_attributes id="VIP_eth2_inst_attr">
               <nvpair id="VIP_eth0_attr_0" name="ip" value="192.168.0.100"/>
               <nvpair id="VIP_eth0_attr_1" name="netmask" value="24"/>
               <nvpair id="VIP_eth0_attr_2" name="nic" value="eth0"/>
           </instance_attributes>
         </primitive>
        </group>

cibadmin -o resources -C -x /tmp/resources.xml

        <constraints>
         <rsc_location id="rsc_location_group_1" rsc="group_1">
          <rule id="prefered_location_group_1" score="100">
           <expression attribute="#uname" id="prefered_location_group_1_expr" operation="eq" value="ha01"/>
          </rule>
         </rsc_location>
        </constraints>

After editing above file, you need to tell Heartbeat to add it to the cluster configuration.

cibadmin -o constraints -C -x /tmp/resources.xml

UbuntuHighAvailabilityTeam/PacemakerHeartbeat (last edited 2009-07-13 22:44:55 by 190)