Sie sind auf Seite 1von 11

Redhat Heartbeat Cluster configuration

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

Private Network: to monitor the heartbeat


[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
IPV6INIT=yes
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.1.0.16
NETMASK=255.255.255.0
USERCTL=no

Virtual IPaddress for apache configuration


[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
HWADDR=00:0c:29:1c:49:87
IPV6INIT=yes
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.168.1.27
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no

[root@node1 /]# ifconfig


eth0

Link encap:Ethernet HWaddr 00:0C:29:1C:49:87


inet addr:192.168.1.25 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1c:4987/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6962 errors:0 dropped:0 overruns:0 frame:0
TX packets:2263 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1078827 (1.0 MiB) TX bytes:310759 (303.4 KiB)

eth1

Link encap:Ethernet HWaddr 00:0C:29:1C:49:91


inet addr:10.1.0.16 Bcast:10.1.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1c:4991/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3498 errors:0 dropped:0 overruns:0 frame:0
TX packets:4696 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:775531 (757.3 KiB) TX bytes:336902 (329.0 KiB)

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:16436 Metric:1
RX packets:18495 errors:0 dropped:0 overruns:0 frame:0

TX packets:18495 errors:0 dropped:0 overruns:0 carrier:0


collisions:0 txqueuelen:0
RX bytes:4531806 (4.3 MiB) TX bytes:4531806 (4.3 MiB)

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

Private Network: to monitor the heartbeat


[root@node2 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none

IPV6INIT=yes
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.1.0.15
NETMASK=255.255.255.0
USERCTL=no

[root@node2 /]# ifconfig


eth0

Link encap:Ethernet HWaddr 00:0C:29:9E:AF:2F


inet addr:192.168.1.26 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9e:af2f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1219 errors:0 dropped:0 overruns:0 frame:0
TX packets:1635 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:159774 (156.0 KiB) TX bytes:344244 (336.1 KiB)

eth1

Link encap:Ethernet HWaddr 00:0C:29:9E:AF:39


inet addr:10.1.0.15 Bcast:10.1.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9e:af39/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:584 errors:0 dropped:0 overruns:0 frame:0

TX packets:557 errors:0 dropped:0 overruns:0 carrier:0


collisions:0 txqueuelen:1000
RX bytes:138515 (135.2 KiB) TX bytes:133253 (130.1 KiB)

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:16436 Metric:1
RX packets:973 errors:0 dropped:0 overruns:0 frame:0
TX packets:973 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:168266 (164.3 KiB) TX bytes:168266 (164.3 KiB)

[root@node2 network-scripts]# cat /etc/sysconfig/network


NETWORKING=yes
HOSTNAME=localhost.localdomain
HOSTNAME=node2
[root@node2 network-scripts]# hostname
node2

Put hosts entry in both the servers.


[root@node1 /]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1

localhost localhost.localdomain localhost6 localhost6.localdomain6

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

localhost localhost.localdomain localhost6 localhost6.localdomain6

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

Download RPM for heartbeat


http://rpm.pbone.net/index.php3

Download RPM for heartbeat-libs


http://rpm.pbone.net/index.php3

Step:3
Install both the packages

#yum install heartbeat *


Note: After installation of package by default all the configuration files will be extracted in
/usr/share/doc/heartbeat-3.0.4.2

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

Change the permission of the authkeys file:


chmod 600 /etc/ha.d/authkeys
5. Moving to our second file (ha.cf) which is the most important. So edit the ha.cf file with vi:
vi /etc/ha.d/ha.cf
Add the following lines in the ha.cf file:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth1
ucast eth1 10.1.0.16
udpport 694
auto_failback on
node node1
node node2
Note: node01 and node02 is the output generated by

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

7. Copy the /etc/ha.d/ directory from node01 to node02:


scp -r /etc/ha.d/ root@nreode02:/etc/

copy the same to node2 and change the ucast ipaddress


Node 02
vi /etc/ha.d/ha.cf
Add the following lines in the ha.cf file:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth1
ucast eth1 10.1.0.15
udpport 694
auto_failback on
node node1
node node2
8. As we want httpd highly enabled let's start configuring httpd:
vi /etc/httpd/conf/httpd.conf
Add this line in httpd.conf:
Listen 192.168.1.27:80
9. Copy the /etc/httpd/conf/httpd.conf file to node02:

scp /etc/httpd/conf/httpd.conf root@node02:/etc/httpd/conf/


10. Create the file index.html on both nodes (node01 & node02):
On node01:
echo "node01 apache test server" > /var/www/html/index.html
On node02:

echo "node02 apache test server" > /var/www/html/index.html

Create a symlink in both the server


#cd /etc/ha.d/resource.d/
#ln -s /etc/init.d/httpd .

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!!!

Das könnte Ihnen auch gefallen