Installing Heartbeat Package

Target nodes for the Heartbeat package are three work nodes with a common virtual IP address. Continuous availability of services is ensured by the Heartbeat package.

NOTE. Main cluster nodes will be further designated as kn0, kn1, kn2, work nodes will be designated as kn3, kn4, kn5. The Heartbeat package can be installed and set up on the kn3, kn4 and kn5 nodes.

To install and set up the Heartbeat package:

  1. Install and set up Heartbeat:

apt-get update && apt-get -y install heartbeat && systemctl enable heartbeat

NOTE. All three servers share the same IP address - <main external cluster ip>. This virtual IP address will be moved between servers that is why you should activate the net.ipv4.ip_nonlocal_bind parameter to enable binding of system services to a non-local IP address.

  1. Add this option to the file /etc/sysctl.conf for the kn3, kn4, kn5 nodes:

# echo ‘net.ipv4.ip_nonlocal_bind=1’ >> /etc/sysctl.conf
# sysctl -p

  1. Create the file /etc/ha.d/authkeys. This file stores Heartbeat data for mutual authentication, and the file must be identical on both work nodes:

# echo -n securepass | md5sum
bb77d0d3b3f239fa5db73bdf27b8d29a

# Where securepass – password for Heartbeat
# Copy the output hash sum to the clipboard

kn3
$ sudo vi /etc/ha.d/authkeys
auth 1
1 md5 bb77d0d3b3f239fa5db73bdf27b8d29a

kn4
sudo  vi /etc/ha.d/authkeys
auth 1
1 md5 bb77d0d3b3f239fa5db73bdf27b8d29a

kn5
sudo vi /etc/ha.d/authkeys
auth 1
1 md5 bb77d0d3b3f239fa5db73bdf27b8d29a

  1. Make sure that the file /etc/ha.d/authkeys is available only for the root user:

Kn3# sudo chmod 600 /etc/ha.d/authkeys
Kn4# sudo chmod 600 /etc/ha.d/authkeys
Kn5# sudo chmod 600 /etc/ha.d/authkeys

  1. Create main configuration files for Heartbeat on the selected servers (files slightly differ for each server):

    1. Create the file /etc/ha.d/ha.cf on the kn3, kn4, kn5 nodes.

NOTE. To get configuration node parameters, execute uname -n on all three servers. Also use the name of your network card instead of ens160.

Kn3# vi /etc/ha.d/ha.cf
#       keepalive: how many seconds between heartbeats
#
keepalive 2
#
#       deadtime: seconds-to-declare-host-dead
#
deadtime 10
#
#       What UDP port to use for udp or ppp-udp communication?
#
udpport        694
bcast  ens160
mcast ens160 225.0.0.1 694 1 0
ucast ens160 <main kn3 ip>
#       What interfaces to heartbeat over?
udp     ens160
#
#       Facility to use for syslog()/logger (alternative to log/debugfile)
#
logfacility     local0
#
#       Tell what machines are in the cluster
#       node    nodename ...    -- must match uname -n
node    kn3
node    kn4
node    kn5

kn4# vi /etc/ha.d/ha.cf
#       keepalive: how many seconds between heartbeats
#
keepalive 2
#
#       deadtime: seconds-to-declare-host-dead
#
deadtime 10
#
#       What UDP port to use for udp or ppp-udp communication?
#
udpport        694
bcast  ens160
mcast ens160 225.0.0.1 694 1 0
ucast ens160 <main kn4 ip>
#       What interfaces to heartbeat over?
udp     ens160
#
#       Facility to use for syslog()/logger (alternative to log/debugfile)
#
logfacility     local0
#
#       Tell what machines are in the cluster
#       node    nodename ...    -- must match uname -n
node    kn3
node    kn4
node    kn5

kn5# vi /etc/ha.d/ha.cf
#       keepalive: how many seconds between heartbeats
#
keepalive 2
#
#       deadtime: seconds-to-declare-host-dead
#
deadtime 10
#
#       What UDP port to use for udp or ppp-udp communication?
#
udpport        694
bcast  ens160
mcast ens160 225.0.0.1 694 1 0
ucast ens160 <main kn5 ip>
#       What interfaces to heartbeat over?
udp     ens160
#
#       Facility to use for syslog()/logger (alternative to log/debugfile)
#
logfacility     local0
#
#       Tell what machines are in the cluster
#       node    nodename ...    -- must match uname -n
node    kn3
node    kn4
node    kn5

    1. Create the file /etc/ha.d/haresources. It contains a common virtual IP address and sets which node is the main one by default. The file must be identical at all nodes:

Kn3# vi /etc/ha.d/haresources
Kn3 <main virtual cluster ip>
Kn4# vi /etc/ha.d/haresources
Kn3 <main virtual cluster ip>
Kn5# vi /etc/ha.d/haresources
Kn3 <main virtual cluster ip>   ### Here and above kn3 - hostname of the node selected as a main one by default for Heartbeat.   

  1. Start Heartbeat services on all nodes and make sure that the specified virtual IP address is set on the kn3 node:

Kn3# systemctl restart heartbeat
Kn4# systemctl restart heartbeat
Kn5# systemctl restart heartbeat
kn1# ip a s
ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
   link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
   inet <main kn3 ip>/24
      valid_lft forever preferred_lft forever
   inet <main cluster ip>/24

  1. Check access by main cluster ip using the command:

nc -v <main cluster ip> 22

Example of command execution result:

Connection to x.x.x.x 22 port [tcp/*] succeeded!
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.7

After executing the operations the Heartbeat package is installed and set up, next prepare Ceph system cluster.

See also:

Preparing Environment for Foresight Mobile Platform | Preparing Ceph System Cluster