In this post, we take a look at the basic HA usage, with two nodes.
In the above figure we have two nodes (raspberry PI with archlinux). Each node runs one HeartBeat instance and communicates (send keepalive) with the other node.
Lets take a look on the installation process.
To successfully install HeartBeat, we need to install two packages (either from AUR repository, or build them from source):
- ha-glue
- ha-heartbeat
- groupadd -r -g 666 haclient
- useradd -r -g haclient -u 666 -d /var/lib/heartbeat/cores/hacluster -s /sbin/nologin -c "cluster user" hacluster
--- lib/plugins/HBcomm/ucast.c.old 2014-09-28 18:28:40.187832720 +0200 +++ lib/plugins/HBcomm/ucast.c 2014-09-28 15:23:31.870568289 +0200 @@ -464,9 +464,9 @@ #if defined(SO_BINDTODEVICE) struct ifreq i; #endif -#if defined(SO_REUSEPORT) - int i = 1; -#endif +//#if defined(SO_REUSEPORT) +// int i = 1; +//#endif UCASTASSERT(mp); ei = (struct ip_private*)mp->pd;Then we have to install some resource agent to manage HeartBeats resources. I've installed ha-resourceagent but not on the raspberry, because I was unable to compile it. So from another machine (x86_64) where the compilation and installation was successful I've copied /etc/ha.d/shellfuncs
and /usr/lib/ocf to both raspberry PI.
HEARTBEAT Configuration:
Basically all we need are 3 configuration files placed in /etc/ha.d/ folder.
Sample configuration files can be found in documentation: /usr/share/doc/heartbeat/
authkeys:
auth 2 2 sha1 HI!heartbeatThis file handles authorization of keepalive packets.
ha.cf:
logfacility local0 keepalive 2 udpport 694 ucast eth0 172.16.0.3 # ip address where will be keepalive sent auto_failback on node RPi-P # list of all nodes node RPi-TYou may need to enable UDP port 694 on iptables.
haresources:
RPi-T IPaddr2::172.16.0.20/24/eth0 # RPi-T is from uname -n, this is the default node for this resource RPi-T IPaddr2::172.16.0.21/24/eth0 RPi-P IPaddr2::172.16.0.22/24/eth0 RPi-P IPaddr2::172.16.0.23/24/eth0
NOTE: haresources must be the same on all nodes.
After startup of HeartBeat on both nodes, we will have following state on eth0 interfaces:
RPi-T ~ # ip addr 4: eth0:mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:eb:33:39:e0 brd ff:ff:ff:ff:ff:ff inet 172.16.0.3/24 brd 172.16.0.255 scope global eth0 valid_lft forever preferred_lft forever inet 172.16.0.20/24 brd 172.16.0.255 scope global secondary eth0 valid_lft forever preferred_lft forever inet 172.16.0.21/24 brd 172.16.0.255 scope global secondary eth0 valid_lft forever preferred_lft forever
RPi-P ~ # ip addr 4: eth0:mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:eb:f7:a4:96 brd ff:ff:ff:ff:ff:ff inet 172.16.0.5/24 brd 172.16.0.255 scope global eth0 valid_lft forever preferred_lft forever inet 172.16.0.22/24 brd 172.16.0.255 scope global secondary eth0 valid_lft forever preferred_lft forever inet 172.16.0.23/24 brd 172.16.0.255 scope global secondary eth0 valid_lft forever preferred_lft forever
No comments:
Post a Comment