Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
in RHel6
In our example we have 2 servers
Public Network
Private Network
Hostname
IPADDRESS
IPADDRESS
node1
192.168.1.25
10.1.0.16
node2
192.168.1.26
10.1.0.15
and need to set one Virtual IP address for node1 - 192.168.1.27
Pre requirement
Step:1 Network setup of heartbeat cluster
Node1:
Public Network
[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:1c:49:87
IPV6INIT=yes
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="7b772c26-87b7-4e08-96c5-79ad804211db"
IPADDR=192.168.1.25
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no
eth1
lo
Node2:
Public Network
[root@node2 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:9e:af:2f
IPV6INIT=yes
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="7b1495c2-28b5-4c81-bd22-58f0272dbeb9"
IPADDR=192.168.1.26
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no
IPV6INIT=yes
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.1.0.15
NETMASK=255.255.255.0
USERCTL=no
eth1
lo
192.168.1.25 node1
192.168.1.26 node2
[root@node2 /]# cat /etc/hosts
27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1
192.168.1.25 node1
192.168.1.26 node2
Step:2
Packages need to install for heartbeat cluster
1) heartbeat-3.0.4-2.el6.x86_64.rpm
2) heartbeat-libs-3.0.4-2.el6.x86_64.rpm
Step:3
Install both the packages
Step 4:
Now we have to configure heartbeat on our two node cluster. We will deal with three files.
These are:
authkeys
ha.cf
haresources
Now moving to our configuration. But there is one more thing to do, that is to copy these files to
the /etc/ha.d directory. In our case we copy these files as given below:
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:5
Now let's start configuring heartbeat. First we will deal with the authkeys file, we will use
authentication method 2 (sha1). For this we will make changes in the authkeys file as below.
vi /etc/ha.d/authkeys
Then add the following lines:
auth 2
2 sha1 test-ha
6. The final piece of work in our configuration is to edit the haresources file. This file contains
the information about resources which we want to highly enable. In our case we want the
webserver (httpd) highly available:
vi /etc/ha.d/haresources
Add the following line:
node1 192.168.1.27 httpd
Note: we can the service for which we need to add in the heartbeat cluster ex:
DNS,DHCP,SAMBA,FTP, SQUID .... in the above file
11. Now start heartbeat on the primary node01 and slave node02:
/etc/init.d/heartbeat start
12. Open web-browser and type in the URL:
http://192.168.1.27
It will show node01 apache test server.
13. Now stop the hearbeat daemon on node01:
/etc/init.d/heartbeat stop
In your browser type in the URL http://192.168.1.27 and press enter.
It will show node02 apache test server.
14. We don't need to create a virtual network interface and assign an IP address (192.168.1.27) to
node2. Heartbeat will do this for you, and start the service (httpd) itself. So don't worry about
this.
Don't use the IP addresses 192.168.1.25 and 192.168.1.26 for services. These addresses are used
by heartbeat for communication between node01 and node02. When any of them will be used for
services/resources, it will disturb hearbeat and will not work. Be carefull!!!