LVS - Load Balancing Detaied Tutorial - Step 1: Basic Configuration

LVS - Load Balancing Detaied Tutorial

Linux Load Balancer using Piranha,Pulse,IPVsadm and Highly Available MySQL using DRBD & HearTBeat.

Source:

http://www.Wbitt.com
Demo: hbn.local

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.

Step 1: Basic configurations

a. Hosts file

#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 #####
192.168.44.101 lvs1.hbn.local lvs1
192.168.44.102 lvs2.hbn.local lvs2

##### IP's of Web Servers #####
192.168.44.131 www1.hbn.local www1
192.168.44.132 www2.hbn.local www2

##### IP's of MySQL DB servers #####
192.168.44.151 db1.hbn.local db1
192.168.44.152 db2.hbn.local db2

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

192.168.44.130 hbn.local www
192.168.44.150 db.hbn.local db

Then, copy this to all the servers
First, generate ssh keys
# ssh-keygen -t rsa
# ssh-keygen -t dsa
# cd /root/.ssh/
# cat *.pub > authorized_keys
Copy:

#scp -r /root/.ssh/ lvs2:/root/

#scp -r /root/.ssh/ www1:/root/

#scp -r /root/.ssh/ www2:/root/

#scp -r /root/.ssh/ db1:/root/

#scp -r /root/.ssh/ db2:/root/

#ssh-keyscan -t dsa lvs1 lvs2 www1 www2 db1 db2

#ssh-keyscan -t rsa lvs1 lvs2 www1 www2 db1 db2

Now, you can ssh from lvs1 don`t need password

Second, copy host file

#scp /etc/hosts lvs2:/etc/

#scp /etc/hosts www1:/etc/

#scp /etc/hosts www2:/etc/

#scp /etc/hosts db1:/etc/

#scp /etc/hosts db2:/etc/

b. NTP synchronize time
Sure ntpd service is installed:

#rpm -qa | grep ntp
If not found:

#yum install -y ntp*

OK:

#rpm -qa | grep ntp
ntp-4.2.2p1-9.el5.centos.2.1

On LVS1, it is local time server:
# vim /etc/ntp.conf

restrict 127.0.0.1

server 127.127.1.0 # local clock

#Uncomment other server.

save and quit :wq

ntpq -q -n
# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]

On lvs2 host:
# vim /etc/ntp.conf

#Comment it:

#restrict 127.0.0.1

#restrict -6 ::1

server 192.168.44.101 ##Put Your Local Server IP here##

#Comment other time servers:

#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 and quit :wq
# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]

#chkconfig ntpd on
# ntpdate -u 192.168.44.101

Note: restrict 127.0.0.1 is you have full access

#scp /etc/ntp.conf www1:/etc/

#scp /etc/ntp.conf www2:/etc/

#scp /etc/ntp.conf db1:/etc/

#scp /etc/ntp.conf db2:/etc/

And, on all other host:
# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]

#chkconfig ntpd on
# ntpdate -u 192.168.44.101
-----------------------------------------------------------
Demo: Video: ( Note: watch with HD quality :))
Part1:

Part2:

Or:

Part1: http://www.mediafire.com/?jh1b82n7fhrrdb8
Part2: http://www.mediafire.com/?819jhhq7kfo78oq
------------------------------------------------------------
Thanks for reading
--------------------------------------------------------------------------
All my Lab:
Linux Lab -- window and Cisco Lab
to be continued - I will update more.

Nam Habach