Part-4:
lvs (Linux virtual server) Active & Backup Load-Balancer settings.
4.1 : Installation piranha package on both load balancer (loadb1, loadb2) servers.
[root@loadb1 ~]# yum install -y piranha Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.syn.co.il * extras: centos.syn.co.il * updates: centosg4.centos.org Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package piranha.x86_64 0:0.8.5-9.el6 will be installed --> Processing Dependency: ipvsadm >= 1.14 for package: piranha-0.8.5-9.el6.x86_64 --> Processing Dependency: php for package: piranha-0.8.5-9.el6.x86_64 --> Running transaction check ---> Package ipvsadm.x86_64 0:1.25-9.el6 will be installed ---> Package php.x86_64 0:5.3.3-3.el6_2.8 will be installed --> Processing Dependency: php-common = 5.3.3-3.el6_2.8 for package: php-5.3.3-3.el6_2.8.x86_64 --> Processing Dependency: php-cli = 5.3.3-3.el6_2.8 for package: php-5.3.3-3.el6_2.8.x86_64 --> Running transaction check ---> Package php-cli.x86_64 0:5.3.3-3.el6_2.8 will be installed ---> Package php-common.x86_64 0:5.3.3-3.el6_2.8 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: piranha x86_64 0.8.5-9.el6 base 619 k Installing for dependencies: ipvsadm x86_64 1.25-9.el6 base 41 k php x86_64 5.3.3-3.el6_2.8 updates 1.1 M php-cli x86_64 5.3.3-3.el6_2.8 updates 2.2 M php-common x86_64 5.3.3-3.el6_2.8 updates 522 k Transaction Summary ================================================================================ Install 5 Package(s) Total download size: 4.4 M Installed size: 18 M Downloading Packages: (1/5): ipvsadm-1.25-9.el6.x86_64.rpm | 41 kB 00:02 (2/5): php-5.3.3-3.el6_2.8.x86_64.rpm | 1.1 MB 00:03 (3/5): php-cli-5.3.3-3.el6_2.8.x86_64.rpm | 2.2 MB 00:05 (4/5): php-common-5.3.3-3.el6_2.8.x86_64.rpm | 522 kB 00:01 (5/5): piranha-0.8.5-9.el6.x86_64.rpm | 619 kB 00:16 -------------------------------------------------------------------------------- Total 141 kB/s | 4.4 MB 00:32 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : php-common-5.3.3-3.el6_2.8.x86_64 1/5 Installing : php-cli-5.3.3-3.el6_2.8.x86_64 2/5 Installing : php-5.3.3-3.el6_2.8.x86_64 3/5 Installing : ipvsadm-1.25-9.el6.x86_64 4/5 Installing : piranha-0.8.5-9.el6.x86_64 5/5 Installed: piranha.x86_64 0:0.8.5-9.el6 Dependency Installed: ipvsadm.x86_64 0:1.25-9.el6 php.x86_64 0:5.3.3-3.el6_2.8 php-cli.x86_64 0:5.3.3-3.el6_2.8 php-common.x86_64 0:5.3.3-3.el6_2.8 Complete!
4.2 : Now install on loadb2.
[root@loadb2 ~]# yum install -y piranha Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.syn.co.il * extras: centos.syn.co.il * updates: centosg4.centos.org Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package piranha.x86_64 0:0.8.5-9.el6 will be installed --> Processing Dependency: ipvsadm >= 1.14 for package: piranha-0.8.5-9.el6.x86_64 --> Processing Dependency: php for package: piranha-0.8.5-9.el6.x86_64 --> Running transaction check ---> Package ipvsadm.x86_64 0:1.25-9.el6 will be installed ---> Package php.x86_64 0:5.3.3-3.el6_2.8 will be installed --> Processing Dependency: php-common = 5.3.3-3.el6_2.8 for package: php-5.3.3-3.el6_2.8.x86_64 --> Processing Dependency: php-cli = 5.3.3-3.el6_2.8 for package: php-5.3.3-3.el6_2.8.x86_64 --> Running transaction check ---> Package php-cli.x86_64 0:5.3.3-3.el6_2.8 will be installed ---> Package php-common.x86_64 0:5.3.3-3.el6_2.8 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: piranha x86_64 0.8.5-9.el6 base 619 k Installing for dependencies: ipvsadm x86_64 1.25-9.el6 base 41 k php x86_64 5.3.3-3.el6_2.8 updates 1.1 M php-cli x86_64 5.3.3-3.el6_2.8 updates 2.2 M php-common x86_64 5.3.3-3.el6_2.8 updates 522 k Transaction Summary ================================================================================ Install 5 Package(s) Total download size: 4.4 M Installed size: 18 M Downloading Packages: (1/5): ipvsadm-1.25-9.el6.x86_64.rpm | 41 kB 00:02 (2/5): php-5.3.3-3.el6_2.8.x86_64.rpm | 1.1 MB 00:03 (3/5): php-cli-5.3.3-3.el6_2.8.x86_64.rpm | 2.2 MB 00:05 (4/5): php-common-5.3.3-3.el6_2.8.x86_64.rpm | 522 kB 00:01 (5/5): piranha-0.8.5-9.el6.x86_64.rpm | 619 kB 00:16 -------------------------------------------------------------------------------- Total 141 kB/s | 4.4 MB 00:32 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : php-common-5.3.3-3.el6_2.8.x86_64 1/5 Installing : php-cli-5.3.3-3.el6_2.8.x86_64 2/5 Installing : php-5.3.3-3.el6_2.8.x86_64 3/5 Installing : ipvsadm-1.25-9.el6.x86_64 4/5 Installing : piranha-0.8.5-9.el6.x86_64 5/5 Installed: piranha.x86_64 0:0.8.5-9.el6 Dependency Installed: ipvsadm.x86_64 0:1.25-9.el6 php.x86_64 0:5.3.3-3.el6_2.8 php-cli.x86_64 0:5.3.3-3.el6_2.8 php-common.x86_64 0:5.3.3-3.el6_2.8 Complete!
4.3 : Edit file /etc/sysconfig/ha/lvs.cf and at the end of this file paste these contents.
serial_no = 161
primary = 192.168.2.1
service = lvs
rsh_command = ssh
backup_active = 1
backup = 192.168.2.2
heartbeat = 1
heartbeat_port = 1050
keepalive = 2
deadtime = 10
network = direct
debug_level = NONE
monitor_links = 1
virtual server1 {
active = 1
address = 192.168.2.100 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 websrv1 {
address = 192.168.2.10
active = 1
weight = 1
}
server websrv2 {
address = 192.168.2.11
active = 1
weight = 1
}
}
4.4 : copy this file on loadb2 using scp
[root@loadb1 ~]# scp /etc/sysconfig/ha/lvs.cf loadb2:/etc/sysconfig/ha/ lvs.cf 100% 7966 7.8KB/s 00:00
4.5 : IP Packet forwarding must b on in sysctl.conf and below packet forwarding paste these line
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
4.6 : ‘sysctl -p’ run this command on loadb1
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 = 68719476736 kernel.shmall = 4294967296
4.7 : copy ‘sysctl.conf’ on loadb2 using scp
[root@loadb1 ~]# scp /etc/sysctl.conf loadb2:/etc/ sysctl.conf 100% 1261 1.2KB/s 00:00
4.8 : ‘sysctl -p’ run this command on loadb2
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 = 68719476736 kernel.shmall = 4294967296
4.9 : Now time to run piranha main daemon (pulse) on both loadb1 and loadb2 servers.
Note : Before Running this command make sure http service is running on both websrv1 and websrv2.
[root@loadb1 ~]# service pulse start Starting pulse: [ OK ]
4.10 : Monitor your log on loadb1
[root@loadb1 ~]# tail -f /var/log/messages Jun 9 15:49:11 loadb1 pulse[7368]: STARTING PULSE AS MASTER Jun 9 15:49:21 loadb1 pulse[7368]: partner dead: activating lvs Jun 9 15:49:21 loadb1 avahi-daemon[2392]: Registering new address record for 192.168.2.100 on eth2.IPv4. Jun 9 15:49:21 loadb1 lvs[7372]: starting virtual service server1 active: 80 Jun 9 15:49:21 loadb1 lvs[7372]: create_monitor for server1/websrv1 running as pid 7381 Jun 9 15:49:21 loadb1 lvs[7372]: create_monitor for server1/websrv2 running as pid 7382 Jun 9 15:49:21 loadb1 nanny[7382]: starting LVS client monitor for 192.168.2.100:80 -> 192.168.2.11:80 Jun 9 15:49:21 loadb1 nanny[7381]: starting LVS client monitor for 192.168.2.100:80 -> 192.168.2.10:80 Part 5 : webservers configurations Jun 9 15:49:21 loadb1 nanny[7382]: [ active ] making 192.168.2.11:80 available Jun 9 15:49:21 loadb1 nanny[7381]: [ active ] making 192.168.2.10:80 available Jun 9 15:49:22 loadb1 ntpd[2532]: Listening on interface #7 eth0:1, 192.168.2.100#123 Enabled Jun 9 15:49:26 loadb1 pulse[7374]: gratuitous lvs arps finished
Note : if your log matches with above log it means your lvs working fine.!
4.11 : Now time to run piranha main daemon (pulse) on loadb2 server.
[root@loadb2 ~]# service pulse start Starting pulse: [ OK ]
Part-5: Webservers Configuration.
Don’t Forget
chkconfig pulse on
