Friday, October 1, 2010

Clustering --- HA Cluster using Heartbeat and DRBD

Heartbeat
Heartbeat is a daemon that provides cluster infrastructure (communication and membership) services to its clients. This allows clients to know about the presence (or disappearance!) of peer processes on other machines and to easily exchange messages with them.
In order to be useful to users, the Heartbeat daemon needs to be combined with a cluster resource manager (CRM) which has the task of starting and stopping the services (IP addresses, web servers, etc.) that cluster will make highly available.
High-availability clusters provide continuous availability of services by eliminating single points of failure and by failing over services from one cluster node to another in case a node becomes inoperative.

Mentioned below are the configuration steps Which I have implemented for our Central Mail Server

Note:- All the following activity has to be issued on both the nodes (Primary and Secondary).
Pre-requisite RPM that need to be installed
rpm -ivh perl-libwww-perl-5.805-1.1.1.noarch.rpm
rpm -ivh perl-Crypt-SSLeay-0.51-11.el5.i386.rpm
rpm -ivh perl-Data-HexDump-0.02-1.el5.centos.noarch.rpm
rpm -ivh perl-Net-DNS-0.59-1.fc6.i386.rpm
rpm -ivh perl-Net-IP-1.25-2.fc6.noarch.rpm
rpm -ivh perl-Net-SSLeay-1.30-4.fc6.i386.rpm
rpm –ivh perl-Net-Telnet-3.03-5.noarch.rpm
rpm -ivh perl-Mail-POP3Client-2.17-1.el5.centos.noarch.rpm
rpm -ivh perl-LDAP-0.33-3.fc6.noarch.rpm
rpm –ivh perl-Convert-ASN1-0.20-1.1.noarch.rpm
rpm –ivh perl-XML-SAX-0.14-5.noarch.rpm
rpm –ivh perl-XML-NamespaceSupport-1.09-1.2.1.noarch.rpm
rpm -ivh perl-MailTools-1.77-1.el5.centos.noarch.rpm
rpm –ivh perl-Net-IMAP-Simple-1.17-1.el5.centos.noarch.rpm
rpm –ivh perl-Net-IMAP-Simple-SSL-1.3-1.el5.centos.noarch.rpm
rpm –ivh perl-TimeDate-1.16-1.el5.centos.noarch.rpm
rpm -ivh openhpi-*
rpmbuild --rebuild perl-Authen-Radius-0.13-1.el5.centos.src.rpm
rpm -ivh /usr/src/redhat/RPMS/noarch/perl-Authen-Radius*
After installing all the dependencies now we are installing heart-beat RPMs.
rpmbuild --rebuild ipvsadm-1.24-8.1.src.rpm
rpm -ivh /usr/src/redhat/RPMS/i386/ipvsadm-*
rpm -ivh heartbeat-2.1.2-3.el5.centos.i386.rpm
rpm –ivh heartbeat-gui-2.1.2-3.el5.centos.i386.rpm
rpm –ivh heartbeat-ldirectord-2.1.2-3.el5.centos.i386.rpm
rpm –ivh heartbeat-pils-2.1.2-3.el5.centos.i386.rpm
rpm –ivh heartbeat-stonith-2.1.2-3.el5.centos.i386.rpm
cp /etc/ha.d/authkeys /etc/ha.d/authkeys.org
vi /etc/ha.d/authkeys
auth 1
1 crc
chmod 600 /etc/ha.d/authkeys
cp /etc/ha.d/ha.cf /etc/ha.d/ha.cf
vi /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast eth0 # Linux
ucast eth0 10.10.10.1
auto_failback on
node node1.pankaj.com
node node2.pankaj.com
cp /etc/ha.d/haresources /etc/ha.d/haresources
vi /etc/ha.d/haresources
node1.pankaj.com 192.168.8.86 dovecot vsftpd autohome
service heartbeat start
We can check the heartbeart (HA) is running. Stop heartbeat on one of the system and try to access either FTP or POP service to check it.

DRBD Configuration

 DRBD is a block device which is designed to build high availability clusters. DRBD takes over the data, writes it to the local disk and sends it to the other host.
Each device (DRBD provides more than one of these devices) has a state, which can be 'primary' or 'secondary'. On the node with the primary device the application is supposed to run and to access the device (/dev/drbdX). Every write is sent to the local 'lower level block device' and to the node with the device in 'secondary' state. The secondary device simply writes the data to its lower level block device. Reads are always carried out locally.
If the primary node fails, heartbeat is switching the secondary device into primary state and starts the application there.

rpm -ivh drbd-8.0.4-1.el5.centos.i386.rpm
rpm –ivh kmod-drbd-8.0.4-1.2.6.18_8.el5.i686.rpm

First we have to decide what all Data partition we have to keep in sync and what all services depend on it, then we have to allocate the same partition on both servers.
Note:- All the following activity has to be issued on both the nodes (Primary and Secondary).
fdisk /dev/sda
sda9 40G /autohome
sda8 100G /var/spool/mail
cp /etc/drbd.conf /etc/drbd.conf.org
vi /etc/drbd.conf
#
# please have a a look at the example configuration file in
# /usr/share/doc/drbd/drbd.conf
#
resource drbd-spoolmail {
protocol C;
startup {
degr-wfc-timeout 120; # 2 minutes.
}
disk {
on-io-error detach;
}
net {
timeout 120;
connect-int 20;
ping-int 20;
max-buffers 2048;
max-epoch-size 2048;
ko-count 30;
}
syncer {
rate 10M;
al-extents 257;
}
on node1.pankaj.com {
device /dev/drbd0;
disk /dev/sda9;
address 10.10.10.1:7788;
meta-disk internal;
}
on node2.pankaj.com {
device /dev/drbd0;
disk /dev/cciss/c0d0p7;
address 10.10.10.2:7788;
meta-disk internal;
}
}
resource drbd-home {
protocol C;
startup {
degr-wfc-timeout 120; # 2 minutes.
}
disk {
on-io-error detach;
}
net {
timeout 120;
connect-int 20;
ping-int 20;
max-buffers 2048;
max-epoch-size 2048;
ko-count 30;
}
syncer {
rate 10M;
al-extents 257;
}
on node1.pankaj.com {
device /dev/drbd1;
disk /dev/sda10;
address 10.10.10.1:7789;
meta-disk internal;
}
on node2.pankaj.com {
device /dev/drbd1;
disk /dev/cciss/c0d0p8;
address 10.10.10.2:7789;
meta-disk internal;
}
}
Then we initialize the DRBD Resource using the following commands:-
drbdadm create-md drbd-home
drbdadm create-md drbd-spoolmail
/etc/init.d/drbd restart
Note: If this command gives error then we have to reboot the system and again check this command.
cat /proc/drbd
If all goes well, the output of the last command should look something like this:
0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent r---
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0
resync: used:0/7 hits:0 misses:0 starving:0 dirty:0 changed:0
act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0
Note: you always can find information about the DRBD status by typing:
cat /proc/drbd
Now, type the following command on the master system:
drbdadm -- --overwrite-data-of-peer primary drbd-home
drbdadm -- --overwrite-data-of-peer primary drbd-spoolmail
cat /proc/drbd
The output should look something like this:
0: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent r---
ns:65216 nr:0 dw:0 dr:65408 al:0 bm:3 lo:0 pe:7 ua:6 ap:0
[>...................] sync'ed: 2.3% (3083548/3148572)K
finish: 0:04:43 speed: 10,836 (10,836) K/sec
resync: used:1/7 hits:4072 misses:4 starving:0 dirty:0 changed:4
act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0
This means it is syncing your disks from the master computer that is set as the primary one to the slave computer that is set as secondary.
Next, create the filesystem by typing the following on the master system:
mkfs.ext3 /dev/drbd0
mkfs.ext3 /dev/drbd1
Check the filesystem is formatted using the mount command
mount /dev/drbd0 /var/spool/mail/
mount /dev/drbd1 /autohome/
After checking then unmount them using umount command
umount /var/spool/mail
umount /autohome
vi /etc/ha.d/haresources
node1.pankaj.com 192.168.8.21 drbddisk::drbd-spoolmail drbddisk::drbd-home Filesystem::/dev/drbd0::/var/spool/mail::ext3 Filesystem::/dev/drbd1::/autohome::ext3 sendmail dovecot saslauthd vsftpd autohome

Note that this document comes without warranty of any kind. But every effort has been made to provide the information as accurate as possible. I welcome emails from any readers with comments, suggestions, and corrections at webmaster_at admin@linuxhowto.in

Copyright © 2012 LINUXHOWTO.IN

No comments:

Post a Comment