Heartbeat Installation & Configuration in UBUNTU
Setup Hosts & HOSTNAME file for both nodes as below:
(Node1)
root@node1:/home/sharif# cat /etc/hostname
node1.hatest.com
root@node1:/home/sharif# cat /etc/hosts
192.168.1.151 node1.hatest.com node1
192.168.1.152 node2.hatest.com node2
(Node2)
root@node2:/home/sharif# cat /etc/hostname
node1.hatest.com
root@node2:/home/sharif# cat /etc/hosts
192.168.1.152 node2.hatest.com node2
192.168.1.151 node1.hatest.com node1
Install heartbeat on both nodes:
root@node1:/home/sharif# apt install heartbeat
Edit below mentioned files as below:
root@node1:/etc/ha.d# vim ha.cf [Create and edit ha.cf ]
keepalive 2
warntime 5
deadtime 15
initdead 90
udpport 694
auto_failback on
ucast ens33 192.168.1.152
logfile /var/log/ha-log
node node1.hatest.com node2.hatest.com
root@node1:/etc/ha.d# vim authkeys
auth 2
2 crc
root@node1:/etc/ha.d# chmod 600 authkeys
[Same for both nodes]
root@node1:/etc/ha.d# vim haresources
node1.hatest.com IPaddr::192.168.1.150/24/ens33:0
Now, we will check & verify the status of Heartbeat (on both Nodes)
root@node1:/etc/ha.d# /etc/init.d/heartbeat status
● heartbeat.service - LSB: High-availability services.
Loaded: loaded (/etc/init.d/heartbeat; bad; vendor preset: enabled)
Active: active (running) since Thu 2018-06-14 14:26:41 +06; 17min ago
Docs: man:systemd-sysv-generator(8)
Process: 30701 ExecStart=/etc/init.d/heartbeat start (code=exited, status=0/SUCCESS)
Main PID: 30811 (heartbeat)
Tasks: 4
Memory: 7.6M
CPU: 1.402s
CGroup: /system.slice/heartbeat.service
├─30811 heartbeat: master control process
├─30833 heartbeat: FIFO reader
├─30834 heartbeat: write: ucast ens33
└─30835 heartbeat: read: ucast ens33
Jun 14 14:26:40 node1.hatest.com systemd[1]: Starting LSB: High-availability services....
Jun 14 14:26:40 node1.hatest.com heartbeat[30701]: Starting High-Availability services: 2018/06/14_14:26:40 INFO: Resource is stopped
Jun 14 14:26:41 node1.hatest.com heartbeat[30701]: Done.
Jun 14 14:26:41 node1.hatest.com systemd[1]: Started LSB: High-availability services..
To verify heartbeat functionality, we can follow below process;
If all previous configurations were set correctly and heartbeat is working properly then our Node1 will be the primary and Node2 will be the secondary node.
Node1’s ifconfig will show something like this:
root@node1:/etc/ha.d# ifconfig
ens33 Link encap:Ethernet HWaddr 00:0c:29:fe:1d:50
inet addr:192.168.1.151 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fefe:1d50/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:100804 errors:0 dropped:0 overruns:0 frame:0
TX packets:43301 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:104170260 (104.1 MB) TX bytes:3451722 (3.4 MB)
ens33:0 Link encap:Ethernet HWaddr 00:0c:29:fe:1d:50
inet addr:192.168.1.150 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:39507 errors:0 dropped:0 overruns:0 frame:0
TX packets:39507 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:4269955 (4.2 MB) TX bytes:4269955 (4.2 MB)
If we stop heartbeat service at Node1, then the boxed configuration will disappear from the Node1’s ifconfig and will appear at Node2’s ifconfig similarly. It is an alias IP address which will dynamically assigned to nodes as per their availability. User will use their desired service against the alias IP (192.168.1.150).
We can also verify the Heartbeat by another process.
Ping manually to alias IP(192.168.1.150) from another same LAN device. We will get the response. We are getting the response from node1 as it is the primary node and it’s IP config has alias IP.
STOP the heartbeat service at Node1 and we will again get ICMP from alias IP(192.168.1.150) after 1/2 packet loss. Now we are getting response from Node2. We can verify it at Node2’s ifconfig. Now Node2’s ifconfig has the alias IP.
Now again start the Heartbeat service of Node1. The alias IP will shift from running Node2 to Node1. We can again verify it from ifconfig of both nodes.
Hope, above steps are clear in understanding. We can complete Heartbeat installation by following above mentioned instructions
Remarks: Please see log of Heartbeat in /var/log/ha-log for any kind of troubleshooting process.
Caution:
While installing Heartbeat please be cautious about below points.
Hosts & Hostname
IP address.
Heartbeat package installation.
Editing of following Heartbeat configuration files:
ha.cf
authkeys [Make sure chmod command used properly]
haresources
Start/Stop Heartbeat service properly whenever needed.
Comments
Post a Comment