Part-5:

Web-Servers Configurations.

Note: in last Part we Started httpd on both websrv1 and websrv2 server.

5.1 : Install php and mysql support on both server using yum.

[root@websrv1 ~]# yum install php php-mysql php* -y

Now Install on websrv2

[root@websrv2 ~]# yum install php php-mysql php* -y

5.2 : Create index.html pages on root directory of both servers using ‘echo’ command.

[root@websrv1 ~]# echo "This is Websrv1" > /var/www/html/index.html
[root@websrv2 ~]# echo "This is Websrv2" > /var/www/html/index.html

5.3 : Restart ‘httpd’ service on both servers.

service httpd restart

5.4 : Create loopBack Adapters on both web servers for Virtual IP ( 192.168.2.100 ).

[root@websrv1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.2.100
NETMASK=255.255.255.255
NETWORK=192.168.2.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)
ONBOOT=yes
NAME=loopback

5.5 : Bring your Interface up & available on startup

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

5.6 : copy this same file on websrv2.

[root@websrv1 ~]# scp /etc/sysconfig/network-scripts/ifcfg-lo:0 websrv2:/etc/sysconfig/network-scripts/

5.7 : on webserv2 Bring your Interface up & available on startup

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

5.8 : Installation arptalbes_jf on both servers using yum that package will get request from load-balancer and serve this request directly to clients.
About arptalbes_jf you can read its behaviour in LVS setup on this link : arptables_jf

[root@websrv1 ~]# yum install arptables_jf -y
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: ftp.cc.uoc.gr
 * extras: ftp.cc.uoc.gr
 * updates: ftp.cc.uoc.gr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package arptables_jf.i686 0:0.0.8-20.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch          Version                Repository     Size
================================================================================
Installing:
 arptables_jf          i686          0.0.8-20.el6           base           57 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 57 k
Installed size: 200 k
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 57 k
arptables_jf-0.0.8-20.el6.i686.rpm                       |  57 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : arptables_jf-0.0.8-20.el6.i686                               1/1

Installed:
  arptables_jf.i686 0:0.0.8-20.el6

Complete!

On websrv2 also

[root@websrv2 ~]# yum install arptables_jf -y
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: ftp.cc.uoc.gr
 * extras: ftp.cc.uoc.gr
 * updates: ftp.cc.uoc.gr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package arptables_jf.i686 0:0.0.8-20.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch          Version                Repository     Size
================================================================================
Installing:
 arptables_jf          i686          0.0.8-20.el6           base           57 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 57 k
Installed size: 200 k
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 57 k
arptables_jf-0.0.8-20.el6.i686.rpm                       |  57 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : arptables_jf-0.0.8-20.el6.i686                               1/1

Installed:
  arptables_jf.i686 0:0.0.8-20.el6

Complete!

5.9 : Add arptables_jf rules for virtual IP.

websrv1

[root@websrv1 ~]# arptables -A IN -d 192.168.2.100 -j DROP
[root@websrv1 ~]# arptables -A OUT -d 192.168.2.100 -j mangle --mangle-ip-s 192.168.2.1
[root@websrv1 ~]# arptables -A OUT -d 192.168.2.100 -j mangle --mangle-ip-s 192.168.2.2

websrv2

[root@websrv2 ~]# arptables -A IN -d 192.168.2.100 -j DROP
[root@websrv2 ~]# arptables -A OUT -d 192.168.2.100 -j mangle --mangle-ip-s 192.168.2.1
[root@websrv2 ~]# arptables -A OUT -d 192.168.2.100 -j mangle --mangle-ip-s 192.168.2.2

Save arptables on both servers

[root@websrv1 ~]# /etc/init.d/arptables_jf save
Saving current rules to /etc/sysconfig/arptables:          [  OK  ]
[root@websrv2 ~]# /etc/init.d/arptables_jf save
Saving current rules to /etc/sysconfig/arptables:          [  OK  ]

if you browse 192.168.2.100 or www.broexperts.com load-balancer will send your requests on Active Real web servers.

Note : You can watch your Traffic on Active load-balancer using.

watch ipvsadm -Lcn

Part-6 : Database Servers Configurations with DRBD and HeartBeat