Redhat Heartbeat Cluster Configuration in RHel6

download Redhat Heartbeat Cluster Configuration in RHel6

of 11

description

Redhat Heartbeat Cluster Configuration

Transcript of Redhat Heartbeat Cluster Configuration in RHel6

Redhat Heartbeat Cluster configuration in RHel6

In our example we have 2 serversPublic Network Private Network HostnameIPADDRESSIPADDRESSnode1 192.168.1.2510.1.0.16 node2192.168.1.2610.1.0.15and need to set one Virtual IP address for node1 - 192.168.1.27

Pre requirementStep:1 Network setup of heartbeat clusterNode1:Public Network[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0BOOTPROTO=noneHWADDR=00:0c:29:1c:49:87IPV6INIT=yesNM_CONTROLLED=yesONBOOT=yesTYPE=EthernetUUID="7b772c26-87b7-4e08-96c5-79ad804211db"IPADDR=192.168.1.25NETMASK=255.255.255.0GATEWAY=192.168.1.1USERCTL=no

Private Network: to monitor the heartbeat[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth1DEVICE=eth1BOOTPROTO=noneIPV6INIT=yesONBOOT=yesTYPE=EthernetIPADDR=10.1.0.16NETMASK=255.255.255.0USERCTL=no

Virtual IPaddress for apache configuration[root@node1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth0:1DEVICE=eth0:1BOOTPROTO=noneHWADDR=00:0c:29:1c:49:87IPV6INIT=yesONBOOT=yesTYPE=EthernetIPADDR=192.168.1.27NETMASK=255.255.255.0GATEWAY=192.168.1.1USERCTL=no

[root@node1 /]# ifconfigeth0 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-eth0DEVICE=eth0BOOTPROTO=noneHWADDR=00:0c:29:9e:af:2fIPV6INIT=yesNM_CONTROLLED=yesONBOOT=yesTYPE=EthernetUUID="7b1495c2-28b5-4c81-bd22-58f0272dbeb9"IPADDR=192.168.1.26NETMASK=255.255.255.0GATEWAY=192.168.1.1USERCTL=no

Private Network: to monitor the heartbeat[root@node2 network-scripts]# cat ifcfg-eth1DEVICE=eth1BOOTPROTO=noneIPV6INIT=yesONBOOT=yesTYPE=EthernetIPADDR=10.1.0.15NETMASK=255.255.255.0USERCTL=no

[root@node2 /]# ifconfigeth0 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/networkNETWORKING=yesHOSTNAME=localhost.localdomainHOSTNAME=node2 [root@node2 network-scripts]# hostnamenode2

Put hosts entry in both the servers.[root@node1 /]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.25 node1192.168.1.26 node2[root@node2 /]# cat /etc/hosts27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.25 node1192.168.1.26 node2

Step:2Packages need to install for heartbeat cluster1) heartbeat-3.0.4-2.el6.x86_64.rpm2) heartbeat-libs-3.0.4-2.el6.x86_64.rpm

Download RPM for heartbeathttp://rpm.pbone.net/index.php3

Download RPM for heartbeat-libs http://rpm.pbone.net/index.php3

Step:3Install 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:authkeysha.cfharesources

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/authkeysThen add the following lines:auth 22 sha1 test-ha

Change the permission of the authkeys file:chmod 600 /etc/ha.d/authkeys5. 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.cfAdd the following lines in the ha.cf file:debugfile /var/log/ha-debuglogfile /var/log/ha-loglogfacility local0keepalive 2deadtime 30initdead 120bcast eth1ucast eth1 10.1.0.16udpport 694auto_failback on

node node1node node2Note: 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/haresourcesAdd 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 02vi /etc/ha.d/ha.cfAdd the following lines in the ha.cf file:debugfile /var/log/ha-debuglogfile /var/log/ha-loglogfacility local0keepalive 2deadtime 30initdead 120bcast eth1ucast eth1 10.1.0.15udpport 694auto_failback on

node node1node node2

8. As we want httpd highly enabled let's start configuring httpd:vi /etc/httpd/conf/httpd.confAdd this line in httpd.conf:Listen 192.168.1.27:809. 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.htmlOn 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 start12. Open web-browser and type in the URL:http://192.168.1.27It will show node01 apache test server.13. Now stop the hearbeat daemon on node01:/etc/init.d/heartbeat stopIn 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!!!