HeartBeat for high availability cluster software in Linux
Linux server environment:
Node1: 192.168.1.100 10.0.0.1
Node2: 192.168.1.102 10.0.0.2
Service: apache
1. Configure the network environment of the system
Node1 node:
[Root @ node1 yum. repos. d] # cd/etc/sysconfig/network-scripts/
[Root @ node1 network-scripts] # vim ifcfg-eth0 -- configure the local IP Address
DEVICE = eth0
HWADDR = 08: 00: 27: EE: 3D: F6
TYPE = Ethernet
UUID = f1fcda7b-0fa1-458d-800c-aeed3d56aad0
ONBOOT = yes
NM_CONTROLLED = yes
BOOTPROTO = static
IPADDR = 192.168.1.100
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.1
[Root @ node1 network-scripts] # vim ifcfg-eth1-configure the heartbeat IP Address
DEVICE = eth1
HWADDR = 08: 00: 27: 06: 79: 47
TYPE = Ethernet
UUID = f1fcda7b-0fa1-458d-800c-aeed3d56aad0
ONBOOT = yes
NM_CONTROLLED = yes
BOOTPROTO = static
IPADDR = 10.0.0.1
NETMASK = 255.255.255.0
[Root @ node1 network-scripts] # vim/etc/hosts -- the IP addresses resolved by node1 and node2
192.168.1.100 node1
192.168.1.102 node2
[Root @ node1 network-scripts] #
Node2 node:
[Root @ node2 ha. d] # cd/etc/sysconfig/network-scripts/
[Root @ node2 network-scripts] # vim ifcfg-eth0 -- configure the IP address of Node 2
DEVICE = eth0
HWADDR = 08: 00: 27: A5: 94: 4C
TYPE = Ethernet
UUID = fd898d33-eed6-4333-a5cd-a6961d9f4226
ONBOOT = yes
NM_CONTROLLED = yes
BOOTPROTO = static
IPADDR = 192.168.1.102
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.1
[Root @ node2 network-scripts] # vim ifcfg-eth1 -- configure the heartbeat IP address of Node 2
DEVICE = eth1
HWADDR = 08: 00: 27: 5B: 2C: 6E
TYPE = Ethernet
UUID = fd898d33-eed6-4333-a5cd-a6961d9f4226
ONBOOT = yes
NM_CONTROLLED = yes
BOOTPROTO = static
IPADDR = 10.0.0.2
NETMASK = 255.255.255.0
[Root @ node2 network-scripts] # vim/etc/hosts -- configure IP Address Resolution
192.168.1.100 node1
192.168.1.102 node2
[Root @ node1 network-scripts] # ping node2-c1 -- check whether the two servers are pinged
PING node2 (192.168.1.102) 56 (84) bytes of data.
64 bytes from node2 (192.168.1.102): icmp_seq = 1 ttl = 64 time = 1.97 MS
--- Node2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 2 ms
Rtt min/avg/max/mdev = 1.974/1.974/1.974/0.000 MS
[Root @ node2 network-scripts] # ping node1-c 1
PING node1 (192.168.1.100) 56 (84) bytes of data.
64 bytes from node1 (192.168.1.100): icmp_seq = 1 ttl = 64 time = 0.524 MS
--- Node1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 1 ms
Rtt min/avg/max/mdev = 0.524/0.524/0.524/0.000 MS
[Root @ node2 network-scripts] #
2. Download The epel source and use the epel source to install the heartbeat software.
Node1 node:
[Root @ node1 network-scripts] # wget http://mirrors3.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm -- Download epel Source
[Root @ node1 yum. repos. d] # rpm-ivh epel-release-6-8.noarch.rpm-install epel Source
Preparing... ######################################## ### [100%]
1: epel-release ##################################### ###### [100%]
[Root @ node1 yum. repos. d] # vim epel. repo -- enable epel Source
Remove the # sign before # baseurl, enabled = 0 to enabled = 1
[Root @ node1 yum. repos. d] # vim epel-testing.repo.
Remove the # sign before # baseurl, enabled = 0 to enabled = 1
[Root @ node1 yum. repos. d] # yum repolist
[Root @ node1 yum. repos. d] # yum install heartbeat *-y -- install heartbeat Software
[Root @ node1 yum. repos. d] # scp epel * node2:/etc/yum. repos. d/-- copy the epel source to node2.
Root @ node2's password:
Epel-release-6-8.noarch.rpm 100% 14KB 14.2KB/s
Epel. repo 100% 954 0.9KB/s
Epel-testing.repo 100% 1054 1.0KB/s
[Root @ node1 yum. repos. d] #
Node2 node:
[Root @ node2 yum. repos. d] # yum repolist
[Root @ node2 yum. repos. d] # yum install heartbeat *-y -- install heartbeat software on node2
3. install apache service test on two nodes
Node1 node:
[Root @ node1 yum. repos. d] # yum install httpd-y -- install apache service
[Root @ node1 yum. repos. d] # echo "node1">/var/www/html/index.html -- write the test page
[Root @ node1 yum. repos. d] #/etc/init. d/httpd stop -- disable the httpd service
[Root @ node1 yum. repos. d] # chkconfig httpd off -- the httpd service is not started when it is started.
Node2 node:
[Root @ node2 yum. repos. d] # yum install httpd-y -- install apache service in node2
[Root @ node2 yum. repos. d] # echo "node2">/var/www/html/index.html -- write the homepage
[Root @ node2 yum. repos. d] #/etc/init. d/httpd stop -- disable the service
[Root @ node2 yum. repos. d] # chkconfig httpd off -- start not
4. Configure HeartBeat cluster Software
[Root @ node1 yum. repos. d] # cd/etc/ha. d/
[Root @ node1 ha. d] # cp-a/usr/share/doc/heartbeat-3.0.4/authkeys. -- copy the configuration file template
[Root @ node1 ha. d] # cp-a/usr/share/doc/heartbeat-3.0.4/haresources.
[Root @ node1 ha. d] # cp-a/usr/share/doc/heartbeat-3.0.4/ha. cf.
[Root @ node1 ha. d] # vim authkeys -- modify authentication information
Auth 3 -- add the two rows
3. md5 1111
[Root @ node1 ha. d] # chmod 600 authkeys -- Modify permissions
[Root @ node1 ha. d] # vim ha. cf
Debugfile/var/log/ha-debug -- # before last year, enable debugging log
Logfile/var/log/ha-log -- # before last year, enable running and access log
Keepalive 2 -- # before last year, heartbeat detection is 2 seconds
Deadtime 30 -- last year's previous #, time of death
Warntime 10 -- number # In front of last year, waiting for 10 seconds
Initdead 120 -- number # before last year, determine the time of death
Bcast eth1 -- add this line and the network adapter to which the multicast address is bound
Auto_failback on -- fault recovery
Node node1 -- add this line and write the host names of the two servers.
Node node2
[Root @ node1 ha. d] # vim haresources -- Define Resources
Node1 192.168.1.105/24/eth1: 0 httpd -- add this line. The host name of node1 master server, 192.168.1.105 virtual IP address, 24 subnet mask, eth1: 0 is the network interface of vip, and httpd is the application service.
[Root @ node1 ha. d] # scp authkeys ha. cf haresources node2:/etc/ha. d/-- copy the three configuration files to node2.
Root @ node2's password:
Authkeys 100% 663 0.7KB/s
Ha. cf 100% 10KB 10.3KB/s
Haresources 100% 5941 5.8KB/s
[Root @ node1 ha. d] #
For more details, please continue to read the highlights on the next page:
-------------------------------------- Split line --------------------------------------
Hot Standby for Web Services Based on Heartbeat V1
Heartbeat enables high-availability clusters of Web Services
Heartbeat + LVS + Ldirectord high-availability Load Balancing Solution
DRBD + Heartbeat + NFS High Availability Configuration notes
Heartbeat high availability for MySQL using NFS based on CRM
Heartbeat high-availability httpd simple configuration based on Resources
-------------------------------------- Split line --------------------------------------