The HA cluster model is as follows: the external vip address is 192.168.2.1, the active web host name node1 and the backup web host name node2. when the master web is dead, the web page in the backup status changes to the master status immediately. To achieve high availability. (Ignore storage)
Node1 Configuration
1. Configure host name and IP address
2. Edit the hosts file so that the master and slave nodes can parse each other.
192.168.2.100 node1.server1.com
192.168.2.200 node2.server2.com
3. Upload the heartbeat software package and install it.
Heartbeat-2.1.4-9.el5.i386.rpm
Heartbeat-pils-2.1.4-10.el5.i386.rpm
Heartbeat-stonith-2.1.4-10.el5.i386.rpm
Libnet-1.1.4-3.el5.i386.rpm
Perl-MailTools-1.77-1.el5.noarch.rpm
Yum localinstall heartbeat-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm perl-MailTools-1.77-1.el5.noarch.rpm-y -- nogpgcheck
4. Copy the heartbeat detection configuration file, resource management configuration file, and identity authentication configuration file to the/etc/ha. d/directory.
Cd/usr/share/doc/heartbeat-2.1.4/
Cp ha. cf authkeys haresources/etc/ha. d/
5. Edit ha. cf and insert it as follows:
Bcast eth1 -- heartbeat detection Interface
Node node1.server1.com -- two nodes
Node node2.server2.com
6. Edit the authkeys file and insert it as follows:
Auth 3
3 md5 adf25a5a79c3be8e1df5ff1ac64a21fc -- the MD5 verification type is followed by the key
Chmod 600 authkeys
7. Edit the haresources file and insert it as follows:
Node1.server1.com 192.168.2.1/24/eth0 httpd (node name (activated) ------- node vip --- script Resource)
8. Copy the httpd control script to the/etc/ha. d/resource. d/directory, and heartbeat will control the httpd service.
Cd/etc/ha. d/resource. d/
Cp/etc/init. d/httpd ./
9. Make sure that httpd is in the stop State and cannot be started, because heartbeat is handed in after control and heartbeat cluster is started.
After the cluster is started, an interface address (vip) is added.
At this time, httpd also starts
That is, node1.server1.com is active, and the following node2.server2.com can only be in the backup status,
The eth0: 0 interface is not generated, and the httpd is also in the stop State.
Node2 is the configuration
The configuration is basically the same as that of node1 (step 1-9 ).
Start the heartbeat cluster of node2.server2.com
Test
Active node1 web
Ping the vip address on a client and set node1.server1.com to the backup status to check whether packet loss exists (you can unplug a line in practice)
Do this
Cd/usr/share/heartbeat/
./Hb_standby ----- simulate failure
Test again
Node2 web, now node2 becomes active
Run the following command if node1.
Cd/usr/share/heartbeat/
./Hb_takeover
In this process, ping is not interrupted, and the high-availability cluster ensures uninterrupted services ...!!!
Recommended reading:
Heartbeat for Linux high availability (HA) Cluster Based on crm
Heartbeat + httpd + NFS for highly available Web Servers
Heartbeat for Linux high availability (HA) CLUSTERS
Heartbeat CRM configuration for Linux high availability solution
High-availability cluster Heartbeat v1 instance
LVS + heartbeat + ldirectord high-availability server Load balancer cluster Solution