Posted by: kezhong | January 16, 2011

Setup a Linux loadbalancer with LVS and ldirectord in tunnelling way

In my past post “Setup a Linux loadbalancer with LVS and ldirectord“, I used direct routing way. In this post, I’ll use the tunneling way. The main advantage of using tunnelling is that real servers can be on a different networks.

The environment was as below.
director: eth0: 192.168.26.201
rs1: eth0: 192.168.26.211
rs2: eth0: 192.168.26.212
VIP: 192.168.26.200

Install packages on Linux Director
# yum install heartbeat*
# yum install ipvsadm
# modprobe ip_vs

Configuration of the Director
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.26.201
NETMASK=255.255.255.0
ONBOOT=yes

# cat /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.26.200
NETMASK=255.255.255.0
ONBOOT=yes

# cat /etc/sysctl.conf
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1

# cat /etc/ha.d/ldirectord.cf
checktimeout=5
checkinterval=1
autoreload=yes
logfile=”/var/log/ldirectord.log”
quiescent=no

virtual=192.168.26.200:80
real=192.168.26.211:80 ipip 10
real=192.168.26.212:80 ipip 10
service=http
scheduler=wrr
protocol=tcp
checktype=negotiate

virtual=192.168.26.200:443
real=192.168.26.211:443 ipip 10
real=192.168.26.212:443 ipip 10
service=https
scheduler=wrr
protocol=tcp
checktype=negotiate
checkport=443

Start service
# service ldirectord start

Configuration of the Real Server 1
# cat /etc/sysconfig/network-scripts/ifcfg-tunl0
DEVICE=tunl0
BROADCAST=192.168.26.200
IPADDR=192.168.26.200
NETMASK=255.255.255.255
ONBOOT=yes

# cat /etc/sysctl.conf
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.tunl0.arp_ignore = 1
net.ipv4.conf.tunl0.arp_announce = 2

Configuration of the Real Server 2
# cat /etc/sysconfig/network-scripts/ifcfg-tunl0
DEVICE=tunl0
BROADCAST=192.168.26.200
IPADDR=192.168.26.200
NETMASK=255.255.255.255
ONBOOT=yes

# cat /etc/sysctl.conf
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.tunl0.arp_ignore = 1
net.ipv4.conf.tunl0.arp_announce = 2


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: