Friday, January 22, 2010

Linux Load Balancer Using LVS, HeartBeat Highly Available MySQL using DRBD & HeartBeat by Babar Zahoor

SkyHi @ Friday, January 22, 2010
Wrritten By Babar Zahooor (RHCE)
Coordinated by Muhammad Farrukh Siddque(LPIC)
Speacial Thanks to
Mr.Muhammad Kamran Azeem

http://www.Wbitt.com, http://www.LinuxUrduCBTs.com

Linsux Load Balancer Video CBT's using Piranha,Pulse,IPVsadm and Highly Available MySQL using DRBD & HearTBeat.


6 Nodes Load Balancer

Two nodes for LVS (Piranha Pulse nannay Ipvsadm) as Load balancer
Two nodes for Web servers can be multiple upto your requirement.
Two nodes for mysql database server using Drbd & heartbeat for highly avaliable mysql database.

3 types of LoadBalancers
1. Nating
2. Direct Routing
3. Tunneling


CentOS 5.3 is used as Operating System.

In this setup we are using LVS(Linux virtual server) using Direct Routing Method these packages are available on Redhat5.x/CentOs5.x.


We will cover these in few steps.

1 . we will setup basic setup for whole 6 nodes

> Host file configuration (In real network use DNS or both.)
> Ssh key generation (For authentication betwen all 6 nodes)
> NTP Configuration (For time syncronization if possible use dedicated NTP server otherwise 1 node can be used)

2 . We need to configure LVS setup for the two highly available Load balancers. (If one down other will do the same function)

3 . We need to configure web servers for the Load balancing the web service. (Both will have apache php php-mysql php-gd service installaed We also install joomla on both server to check our web and Mysql service working.)

4 . We need to configure Drbd & heartbeat service on two db servers.(Db1 and Db2 will be active passive mode to give highly availabe mysql database service and it's data/databses).

5 . We need to configure joomla on both web server's and make thier connection with mysql databses servers.







1. Basic configurations of all 6 nodes.

On all Nodes. Please copy this file on all servers/nodes

[root@lb1 /]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

##### IP's of Load Balancers #####
10.0.0.1 lb1.linuxurducbts.com lb1
10.0.0.2 lb2.linuxurducbts.com lb2

##### IP's of Web Servers #####
10.0.0.30 www1.linuxurducbts.com www1
10.0.0.40 www2.linuxurducbts.com www2

##### IP's of MySQL DB servers #####
10.0.0.50 db1.linuxurducbts.com db1
10.0.0.51 db2.linuxurducbts.com db2

########## Here is Virtual IP/Service IP of Webserver and MySQL DB ##########

10.0.0.3 www.linuxurducbts.com www
10.0.0.190 db.linuxurducbts.com db


Copy this /etc/hosts file to all the servers


[root@lb1 /]#


Now generate ssh keys

[root@lb1 ~]# ssh-keygen -t rsa


[root@lb1 ~]# ssh-keygen -t dsa


[root@lb1 ~]# cd /root/.ssh/


[root@lb1 ~]# cat *.pub > authorized_keys


[root@lb1 ~]#scp -r /root/.ssh/ lb2:/root/


[root@lb1 ~]#scp -r /root/.ssh/ www1:/root/


[root@lb1 ~]#scp -r /root/.ssh/ www2:/root/


[root@lb1 ~]#scp -r /root/.ssh/ db1:/root/


[root@lb1 ~]#scp -r /root/.ssh/ db2:/root/


[root@lb1 ~]#ssh-keyscan -t dsa lb1 lb2 db1 db2 www1 www2

[root@lb1 ~]#ssh-keyscan -t rsa lb1 lb2 db1 db2 www1 www2


Stop Unwanted services on all nodes.


[root@lb1 ~]# /etc/init/sendmail stop


[root@lb1 ~]# chkconfig --level 235 sendmail off


3. NTP configuration.

Run this command on all nodes & Make sure the ntp is installed on all nodes.

[root@lb1 ~]# rpm -qa | grep ntp
ntp-4.2.2p1-9.el5.centos
chkfontpath-1.10.1-1.1
[root@lb1 ~]#
[root@lb1 ~]# vim /etc/ntp.conf ###Configuration for NTP server###
restrict 127.0.0.1

server 127.127.1.0 # local clock


save & quit
[root@lb1 ~]#
[root@lb1 ~]# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]
[root@lb1 ~]#



Clinet side configuration

[root@db2 /]# vim /etc/ntp.conf

#restrict 127.0.0.1
#restrict -6 ::1



server 10.0.0.1 ##Put Server IP here##

#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org


#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10


save & quit


[root@db2 /]# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]
[root@db2 /]#


[root@db2 /]#
[root@db2 /]# ntpdate -u 10.0.0.1
16 Jul 11:55:34 ntpdate[12101]: step time server 10.0.0.1 offset -3.069414 sec
[root@db2 /]#

Copy this file /etc/ntp.conf on all 4 nodes .i.e www1 www2 db1 db2 and restart the ntp service on those nodes.

Run this command on all nodes.

[root@db2 /]# ntpdate -u 10.0.0.1




LVS Setup configuration on LB1 and LB2

We need to install Piranha package it will automaticaly instll pulse,ipvsadm,nanny



install piranha on both nodes


[root@lb1 ~]# yum install piranha -y


[root@lb2 ~]# yum install piranha -y

[root@lb1 ~]# vim /etc/sysconfig/ha/lvs.cf

serial_no = 14
primary = 10.0.0.1
service = lvs
rsh_command = ssh
backup_active = 1
backup = 10.0.0.2
heartbeat = 1
heartbeat_port = 1050
keepalive = 2
deadtime = 10
network = direct ### use nat if nating method is used ###
debug_level = NONE
monitor_links = 1
virtual server1 {
active = 1
address = 10.0.0.3 eth0:1
port = 80
send = "GET / HTTP/1.1\r\n\r\n"
expect = "HTTP"
load_monitor = uptime
scheduler = rr
protocol = tcp
timeout = 10
reentry = 180
quiesce_server = 0
server www1 {
address = 10.0.0.30
active = 1
weight = 1
}
server www2 {
address = 10.0.0.40
active = 1
weight = 1
}
}


save & exit

[root@lb1 ~]# scp /etc/sysconfig/ha/lvs.cf lb2:/etc/sysconfig/ha/

[root@lb1 ~]# cat /etc/sysctl.conf

net.ipv4.ip_forward = 1

net.ipv4.conf.eth0.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.eth0.arp_announce = 2



save & exit


[root@lb1 ~]# scp /etc/sysctl.conf lb2:/etc/

Run this command on both nodes


[root@lb1 ~]# [root@lb1 ~]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
[root@lb1 ~]#



Before starting service pulse start httpd on both web servers.

[root@www1 ~]#/etc/init.d/httpd start
[root@www1 ~]#/etc/init.d/httpd start

Start pulse service on both lvs/LoadBalancer servers

[root@lb1 ~]# /etc/init.d/pulse start
Starting pulse:
[root@lb1 ~]#


[root@lb1 ~]# /etc/init.d/pulse restart
Shutting down pulse: [ OK ]
Starting pulse: [ OK ]
[root@lb1 ~]# tail -f /var/log/messages
Jul 16 12:24:18 lb1 pulse[6363]: STARTING PULSE AS MASTER
Jul 16 12:24:28 lb1 pulse[6363]: partner dead: activating lvs
Jul 16 12:24:28 lb1 avahi-daemon[2940]: Registering new address record for 10.0.0.3 on eth0.
Jul 16 12:24:28 lb1 lvs[6367]: starting virtual service server1 active: 80
Jul 16 12:24:28 lb1 nanny[6376]: starting LVS client monitor for 10.0.0.3:80
Jul 16 12:24:28 lb1 lvs[6367]: create_monitor for server1/www1 running as pid 6376
Jul 16 12:24:28 lb1 nanny[6377]: starting LVS client monitor for 10.0.0.3:80
Jul 16 12:24:28 lb1 lvs[6367]: create_monitor for server1/www2 running as pid 6377
Jul 16 12:24:28 lb1 nanny[6376]: [ active ] making 10.0.0.30:80 available
Jul 16 12:24:28 lb1 nanny[6377]: [ active ] making 10.0.0.40:80 available
Jul 16 12:24:33 lb1 pulse[6369]: gratuitous lvs arps finished



it seems good now our pulse is working fine.


3. Web servers configuration On both servers.

[root@www1 ~]# yum install httpd php php-mysql php-gd

[root@www1 ~]# yum install arptables_jf


[root@www1 ~]#echo "Babar Zahoor
RHCE" > /var/www/html/test.html


[root@www2 ~]#echo "Muhammad db2 Siddique
LPIC" > /var/www/html/test.html


For both server we need to configure the Loopback interface

[root@www1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=10.0.0.3
NETMASK=255.255.255.255
NETWORK=10.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=10.255.255.255
ONBOOT=yes
NAME=loopback
[root@www1 ~]#
[root@www1 ~]#ifup lo:0


[root@www2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=10.0.0.3
NETMASK=255.255.255.255
NETWORK=10.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=10.255.255.255
ONBOOT=yes
NAME=loopback
[root@www2 ~]#
[root@www2 ~]# ifup lo:0


on both real servers

[root@www1 ~]#arptables -A IN -d 10.0.0.3 -j DROP
[root@www1 ~]#arptables -A OUT -d 10.0.0.3 -j mangle --mangle-ip-s 10.0.0.1
[root@www1 ~]#arptables -A OUT -d 10.0.0.3 -j mangle --mangle-ip-s 10.0.0.2
[root@www1 ~]#
[root@www1 ~]# /etc/init.d/arptables_jf save
Saving current rules to /etc/sysconfig/arptables: [ OK ]
[root@www1 ~]#


[root@www2 ~]#arptables -A IN -d 10.0.0.3 -j DROP
[root@www2 ~]#arptables -A OUT -d 10.0.0.3 -j mangle --mangle-ip-s 10.0.0.1
[root@www2 ~]#arptables -A OUT -d 10.0.0.3 -j mangle --mangle-ip-s 10.0.0.2
[root@www2 ~]# /etc/init.d/arptables_jf save
Saving current rules to /etc/sysconfig/arptables: [ OK ]
[root@www2 ~]#

We need to tell system to up lo:0 every time at boot.

[root@www1 ~]# echo "ifup lo:0" > /etc/rc.local
[root@www2 ~]# echo "ifup lo:0" > /etc/rc.local


Here we need to test the setup is working fine here we have two lvs and webservers


this command will show about the connections.



[root@lb1 ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP www.linuxurducbts.com:ht rr
-> www2.linuxurducbts.com:h Route 1 0 0
-> www1.linuxurducbts.com:h Route 1 0 0
[root@lb1 ~]#


[root@lb1 ~]# watch ipvsadm -Lcn




Configuration of Drbd & Heartbeat on Both database servers

Here we need to configure partitions on both servers


PARTITION SETUP On Both Servers.


Partion setup on both server identical same with fdisk


We have 4GB disks on both servers.

Partition Setup for Cluster Servers


We need to create LVM partition




[root@db1 ~]# fdisk -l



[root@db1 ~]# fdisk /dev/sdb


[root@db1 ~]# fdisk /dev/sd
sda sda1 sda2 sdb sdb1
[root@db2 ~]# fdisk /dev/sdb

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 522 4192933+ 8e Linux LVM

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): +4000M

Command (m for help): p

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 487 3911796 83 Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 487 3911796 8e Linux LVM

Command (m for help):

Command (m for help): w


[root@db1 ~]# partprobe



Create Physical Volume for LVM this is second step for LVM partition.


[root@db1 ~]# pvcreat /dev/sdb1 /dev/sdb2


Create Volume Group with this command


[root@db1 ~]# vgcreate vgdb /dev/sdb1


Create Logical volume partition


[root@db1 ~]# lvcreate -L +1000M -n /dev/mapper/vgdb/lvdb
[root@db1 ~]# lvcreate -L +256M -n /dev/mapper/vgdb/lvmeta

Note: Create LVM on Both servers identical same ...................


install drbd and configure it.

[root@db1 ~]# yum install drbd82 kmod-drbd82 -y

[root@db2 ~]# yum install drbd82 kmod-drbd82 -y


[root@db1 ~]modprobe drbd

[root@db2 ~]modprobe drbd

[root@db1 ~]echo "modprobe drbd" > /etc/rc.local

[root@db2 ~]echo "modprobe drbd" > /etc/rc.local




[root@db1 ~]#vim /etc/drbd.conf




global {
usage-count yes;
}



common {
syncer { rate 10M; }
}


resource r0 {
protocol C;
handlers {
pri-on-incon-degr "echo o > /proc/sysrq-trigger ; halt -f";
pri-lost-after-sb "echo o > /proc/sysrq-trigger ; halt -f";
local-io-error "echo o > /proc/sysrq-trigger ; halt -f";
outdate-peer "/usr/lib/heartbeat/drbd-peer-outdater -t 5";
}

startup {
}

disk {
on-io-error detach;
}

net {
after-sb-0pri disconnect;
after-sb-1pri disconnect;
after-sb-2pri disconnect;
rr-conflict disconnect;
}

syncer {
rate 10M;
al-extents 257;
}

on db1.linuxurducbts.com {
device /dev/drbd0;
disk /dev/vgdb/lvdb;
address 10.0.0.50:7788;
meta-disk /dev/vgdb/lvmeta[1];
}

on db2.linuxurducbts.com {
device /dev/drbd0;
disk /dev/vgdb/lvdb;
address 10.0.0.51:7788;
meta-disk /dev/vgdb/lvmeta[1];
}

}



save & exit

[root@db1 ~]#scp /etc/drbd.conf lb2:/etc/
[root@db1 ~]#vi /etc/sysctl.conf

net.ipv4.conf.eth0.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.eth0.arp_announce = 2



save & quit




[root@db1 ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
[root@db1 ~]#


save it........

[root@db1 ~]#
[root@db1 ~]# scp /etc/drbd.conf db2:/etc/drbd.conf


We need to run module on both servers to run drbd


Load DRBD module both nodes:



[root@db1 ~]# modprobe drbd


[root@db1 ~]# echo "modprobe drbd" >> /etc/rc.local

[root@db2 ~]# modprobe drbd


[root@db2 ~]# echo "modprobe drbd" >> /etc/rc.local



##### run this on both servers ######

[root@db1 ~]#drbdadm create-md r0

[root@db2 ~]#drbdadm create-md r0


[root@db1 ~]#drbdadm attach r0

[root@db2 ~]#drbdadm attach r0


[root@db1 ~]#drbdadm syncer r0

[root@db2 ~]#drbdadm syncer r0

[root@db1 ~]#drbdadm connect r0

[root@db2 ~]#drbdadm connect r0



On Primary Node only


[root@db1 ~]#drbdadm -- --overwrite-data-of-peer primary r0


On both Nodes:


[root@db1 ~]#drbdadm up all

[root@db2 ~]#drbdadm up all

On Primary Node only



[root@db1 ~]#drbdadm -- primary all #### ON Node one Only ####




[root@db1 ~]#watch cat /proc/drbd





only on db1 ########## Primary Node ########


[root@db1 ~]#mkfs.ext3 /dev/drbd0


[root@db1 ~]#mkdir /data/

[root@db1 ~]#mount /dev/drbd0 /data/

[root@db1 ~]#
[root@db1 ~]# df -hk
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5967432 2625468 3033948 47% /
/dev/sda1 101086 12074 83793 13% /boot
tmpfs 257720 0 257720 0% /dev/shm
/dev/drbd0 4031516 107600 3719128 3% /data
[root@db1 ~]#
[root@db1 ~]# umount /dev/drbd0 /data

Note: HeartBeat will automatically handle this.

On db2 ####### Secondry Node #######

[root@db2 ~]#mkdir /data



Heartbeat Setup:
================

Install heartbeat package using yum

Note: Internet connection is required or configure yum repository on your local machine with extras.


[root@db1 ~]#yum install -y heartbeat heartbeat-pils heartbeat-stonith heartbeat-devel


[root@db1 ~]#vim /etc/ha.d/ha.cf ## Create this file and copy this text ##

logfacility local0
keepalive 2
#deadtime 30 # USE THIS!!!
deadtime 10
# we use two heartbeat links, eth2 and serial 0
bcast eth0
#serial /dev/ttyS0
baud 19200
auto_failback off
node db1.linuxurducbts.com
node db2.linuxurducbts.com


save & quit.



Server db1

[root@db1 ~]#vi /etc/ha.d/haresources

db1 IPaddr::10.0.0.190/8/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 squid

Server db2:

[root@db2 ~]#vi /etc/ha.d/haresources

db2 IPaddr::10.0.0.190/8/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 squid

On Both Servers:

[root@db1 ~]#vi /etc/ha.d/authkeys

auth 3
3 md5 redhat ######### Use Long name as password #########

both NODE:


[root@db1 ~]#chmod 600 /etc/ha.d/authkeys


[root@db1 ~]#scp /etc/ha.d/authkeys db2:/etc/ha.d/authkeys



[root@db1 ~]#chkconfig --level 235 heartbeat on




Note: if you have problem mounting /dev/drbd0 on /data then run these commands to check the status if you found the drbddisk stopped then start it.





Mysql Configuration.


cp /etc/my.cnf /etc/my.cnf.orig

vi /etc/my.cnf

[mysqld]
# datadir=/var/lib/mysql
datadir=/data/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/data/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
#basedir=/var/lib
basedir=/data

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysql]
socket=/data/mysql/mysql.sock


Now it is time to add users/hosts to mysql server:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.0.30' IDENTIFIED BY 'redhat'
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.0.40' IDENTIFIED BY 'redhat'
mysql> FLUSH PRIVILEGES;


mysql>quit



Now we need to install joomla on both web servers

On Webserver 1

[root@www1 /]# yum install php php-mysql php-gd -y

[root@www1 ~]# ls
anaconda-ks.cfg Desktop install.log install.log.syslog Joomla_1.5.13-Stable-Full_Package
[root@www1 ~]# cd Joomla_1.5.13-Stable-Full_Package/
[root@www1 Joomla_1.5.13-Stable-Full_Package]# ls
[root@www1 Joomla_1.5.13-Stable-Full_Package]# cp -avr * /var/www/html/

[root@www1 Joomla_1.5.13-Stable-Full_Package]# cd /var/www/html/
[root@www1 html]# ls
[root@www1 html]# cd ..
[root@www1 www]# ls
cgi-bin error html icons
[root@www1 www]# chown apache:apache html/ -R
[root@www1 www]#
[root@www1 www]# ls
cgi-bin error html icons
[root@www1 www]# cd html/
[root@www1 html]# ll
[root@www1 html]#

Now open internet explorer then open
http://10.0.0.30

Install Joomla follow the steps and give required information.


In Database section give

Host 10.0.0.190 IP use MySQL as database.
user root
passwdor redhat
database joomla


Must check install sample data.

Copy all the joomla code on www2


[root@www1 html]# scp -r * www2:/var/www/html/

We need to open this file and edit it on line 391 add index.php

[root@www1 html]#vim /etc/httpd/conf/httpd.conf

DirectoryIndex index.html index.html.var index.php


save & quit

[root@www1 /]#
[root@www1 ~]# scp /etc/httpd/conf/httpd.conf www2:/etc/httpd/conf/
httpd.conf 100% 33KB 32.9KB/s 00:00
[root@www1 ~]#
[root@www1 ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@www1 ~]#

On Web Server 2
[root@www2 html]# chown apache:apache * -R
[root@www2 html]# ll
[root@www2 /]# yum install php php-mysql php-gd -y


[root@www2 ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@www2 ~]#



Remeber that each machine(LVS+Real) must have default gw the ip of router connected to these servers

[root@www1 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth0
0.0.0.0 10.0.0.20 0.0.0.0 UG 0 0 0 eth0
[root@www1 ~]#

Now you can test all the network by accessing web on http://10.0.0.3 or http://www.LinuxUrudCBTs.com

[root@lb1 ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP www.linuxurducbts.com:ht rr
-> www2.linuxurducbts.com:h Route 1 0 0
-> www1.linuxurducbts.com:h Route 1 0 0
[root@lb1 ~]#


[root@lb1 ~]# watch ipvsadm -Lcn


ALLHADULILLAH We have done it................

Reference: http://baberzahoor.blogspot.com/2009/07/linux-load-balancer-using-lvs-heartbeat.html