Here the Heatbeat Program is configured to work over a seperate physical connection between the 2 servers (over the private switch). The seperate connection between the 2 servers can be either a serial cable or another ethernet network connection via cross-over cable or a mini switch.
Do note that it is recommended to use at least 2 seperate physical connection to eliminate a single point of failure. As such both of your servers will need 2 phyiscal NIC to allow this 2 seperate physical connection design
Step 1: Configuring the IP addresses
Firstly, do note that RFC 1918 defines the following IP addresses for private network
10.0.0.0 to 10.255.255.255 (10/8 prefix) 172.16.0.0. to 172.31..255.255 (172.16/12 prefix) 192.168.0.0 to 192.168.255.255 (192.168/16 prefix)
For the master node, I will be configuring the IP Addresses as followed:
192.168.1.2 for eth0 (private LAN for the private physical path for the the heartbeat) 172.16.1.2 for eth1 (existing corporate LAN for the other physcial path for the heartbeat
For the slave node, I will be configuring the IP Addresses as followed:
192.168.1.3 for eth0 (private LAN for the private physical path for the heartbeat) 172.16.1.3 for eth1 (existing corporate LAN for the other physical path for the heartbeat)
For the Virtual IP Address, I will be configuring the IP Addresses as followed:
172.16.1.1 (for Virtual Address)
Verify the name of the master node and slave nodes
uname -n (n01 for master node; n02 for slave node)
Step 2: Install and configure the Heartbeat
# yum install heartbeat
Now we have to configure 3 of the files for the 2 nodes. They are
authkeys ha.cf haresources
Copy the sample files to the /etc/ha.d directory
cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/ cp /usr/share/doc/heartbeat-2.1.2/ha.cf /etc/ha.d/ cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/
Step 3: Configuring the /etc/ha.d/ha.cf
logfile /var/log/ha-log logfacility local warntime 5 keepalive 2 deadtime 15 initdead 60 bcast eth0 eth1 udpport 694 auto_failback off node n01 n02
- keepalive – specifies how many seconds there should be there between heartbeats
- deadtime – specifies how many seconds how long the backup will wait without receiving a heartbeat from the primary server before taking over
- initdead – specifies that after the heartbeat daemon starts, it should wait 120 seconds before starting any resources on the primary server.
- warntime – issues a warning that a no longer available peer node may be dead
- nodes n01 n02 is generated by uname -n
- auth_failback off – If the master server fail, the slave server will hold up the resources and will not return the control to the master server when it is brought back live. If auth_failover on, once the master server is brought back online, the slave server will return the resource back to the master server
Step 4: Configure the /etc/ha.d/authkeys
Edit and uncomment the line so that the lines inside /etc/ha.d/authkeys so like this
auth 1 1 sha 1 password
- 1 – is a simple key index, starting with 1
- sha 1 – the signature algorithm being used. You may use either md5 or sha1
- password – refer to the password you create. Make sure it is the same on both systems
Change the permission of the authkeys file
chmod 600 /etc/ha.d/authkeys
Step 5: Configure /etc/ha.d/haresources
The /etc/ha.d/haresources file contain the name of the resources the master server should own. Name of resources are usually a scripts found in /etc/init.d/(script) or /etc/ha.d/resource.d directory. If you stop the heartbeat daemon, you will stop the resource daemon (For example httpd) will not run.
n01 httpd
(where n01 is the master server and the httpd is the resource daemon handled by heartbeat )
Step 6: Install the Heartbeat and configure the backup server
Install the heart-beat according to Step 2. Next copy all the configuration file to the slave server
scp -r /etc/ha.d/ root@n02:/etc/
Copy the resource daemon heartbeat is running from the master server to the slave server. For this example, we will assume httpd
scp /etc/httpd/conf/httpd.conf root@n02:/etc/httpd/conf/
Step 7: Start and test the heartbeat on master (n01) and slave nodes (n02)
/etc/init.d/heartbeat start http://172.16.1.1/ (Virtual IP Address)
Stop the master node heartbeat and type http://172.16.1.1/
/etc/init.d/heartbeat stop http://172.16.1.1/ (Virtual IP Address)
(n02 should show hold the daemon)
Further reading:
- Deploying ipfail plug-in for HeartBeat (Linux Cluster)
For more information, do look at
This is great article. But i have a doubt where we need to create virtual ip in Master or slave or in both
LikeLike
Hi,
is “linux virtual server” still available and up to date?
Thanks
T.
LikeLike