+91 9619904949

LVS

LVS (Linux Virtual Server) ?
The Linux Virtual Server is a highly scalable and highly available server built on a cluster of real servers, with the load balancer running on the Linux operating system. The architecture of the server cluster is fully transparent to end users, and the users interact as if it were a single high-performance virtual server.

Applications of the Linux Virtual Server
The Linux Virtual Server as an advanced load balancing solution can be used to build highly scalable and highly available network services, such as scalable web, cache, mail, ftp, media and VoIP services.

LDIRECTORS:
ldirectord is a daemon to monitor and administer real servers in a LVS cluster of load balanced virtual servers.
ldirectord typically used as a resource for heartbeat , but can also be run from the command line.

A LVS cluster consists or one or more virtual services each of which may have zero or more real servers. The IP address of a virtual service is what end-users connect to and is typically advertised over DNS. When a connection is made to a virtual service, it is allocated a real server, and all packets for this connection are forwarded to this real server. A more detailed overview of LVS can be found here.

ldirectord monitors the health of the real servers by periodically requesting a known URL and checking that the response contains an expected response. If a real server fails then the server is removed and will be reactivated once it comes back on line. If all the real servers are down then a fall-back server is inserted into the pool, which will made quiescent one of the real web servers comes back on line. Typically, the fall-back server is local host. If an HTTP virtual service is being provided then it is useful to run an Apache HTTP server that returns a page indicating that the service is temporarily inaccessible.

HARTBIT:
It is the private connection between two servers.
IF one goes down another will automatically up.

Things needs To Install LDIRECTORS:

yum install heartbeat-ldirectord-2.0.8-3.el5.centos (Plz use above version only)
yum install perl-DBI.x86_64
yum search DBI
yum install perl-DBI
yum search DBD-mysql
yum install perl-DBD-MySQL

To stop & start ldirecrtors
ldirectord -d start
ldirectord -d stop

How To Configure ldirectors:

Create /etc/ha.d/ldirectord.cf

[root@LVS1 ~]# cat  /etc/ha.d/ldirectord.cf ——————————— Main Configuration file
checktimeout=10 ————————- Timeout in seconds for connect, external and ping checks.
checkinterval=5 ————————- Defines the number of second between server checks
#fallback=127.0.0.1:80
autoreload=yes ————————-Defines if <ldirectord> should continuously check the
Configuration file for modification. If this is set to ‘yes’ and the configuration file changed on disk and
its modification time (mtime) is newer than the previous version, the configuration is automatically reloaded.
logfile=”/var/log/ldirectord.log” ####touch /var/log/ldirectord.log ————————-ldirectors logs
#logfile=”local0″
#emailalert=”[email protected]
#emailalertfreq=3600
#emailalertstatus=all
quiescent=yes ————————- If yes, then when real or failback servers are determined
to be down, they are not actually removed from the kernel’s LVS table. Rather, their weight is set to zero which means
that no new connections will be accepted.

#Sample configuration for a MySQL virtual service.
virtual =10.11.1.165:3306 —————Virtual IP & Port for Load balance
real=10.11.1.157:3306 masq ————— Real Server IP
real=10.11.1.26:3306 masq ————– Real Server IP
#fallback=127.0.0.1:3306
service=mysql —————–Which service is used by server
scheduler=wrr (waited round robin) ————— Scheduler to be used by LVS for loadbalancing.
persistent=600 —————  On Client side active connection will refresh after 600 sec
netmask=255.255.255.0
protocol=tcp ————— Protocol used for communication
checktype=negotiate ————— Check the connectivity of real server
Negotiate sends a request and matches a receive string.
Connect only attempts to make a TCP/IP connection,This is useful to check often if a service answers and
in much longer intervals a negotiating check is done
login=”blackpostuser” ———-To check the connectivity it will use following line
passwd=”NitwingsPassword”
database=”blackpost”
request=”SELECT 1;”

[root@LVS1 ~]#

 

Run following on LVS directors
echo “1” >/proc/sys/net/ipv4/ip_forward
echo “0” >/proc/sys/net/ipv4/conf/all/send_redirects
echo “0” >/proc/sys/net/ipv4/conf/default/send_redirects
echo “0” >/proc/sys/net/ipv4/conf/eth0/send_redirects

on real server change gateway to virtual ip
route del -net 10.11.0.0 netmask 255.255.0.0 dev eth1
route del -net 10.11.1.0 netmask 255.255.255.0 dev eth0

service ldirectord start
vi /etc/ha.d/ldirectord.cf
service ldirectord stop
service ldirectord start

ipvsadm -L
ldirectord –debug stop

Heart beat installation
Yum install heartbeat
Please check
Ha.cf

USED FOR HARTBIT FUNTION
Configuring ha.cf :
It tells heartbeat what types of media paths to use and how to configure them . ha.cf. This is placed in the /etc/ha.d directory that is created after installation.

cat /etc/ha.d/ha.cf
#logfacility daemon # This is deprecated
keepalive 1  —————— Sets the time between heartbeats to 1 seconds.
deadtime  10 —————— Node is pronounced dead after 10 seconds.
warntime  5  —————— Time in seconds before issuing a late heartbeat warning in the logs.
initdead  60 —————— With some configurations, the network

takes some time to start working after a reboot.
It should be at least twice the normal deadtime.

#bcast eth0
mcast eth0 229.0.0.1 690 1 0 ———— The mcast directive is used to configure a multicast communication path.

The syntax of an mcast directive is:
mcast dev mcast-group udp-port ttl 0
node lb1.blackpost.net
node lb2.blackpost.net

#crm yes
use_logd yes ————– Use system logging.
logfile /var/log/hb.log ———— Heartbeat logfile.
debugfile /var/log/heartbeat-debug.log — Debugging logfile.
auto_failback no ———— The auto_failback option determines whether

a resource will automatically fail back to
its “primary” node, or remain on whatever
node is serving it until that node fails,
or an administrator intervenes.

#respawn root /usr/lib64/heartbeat/mgmtd -v

uuidfrom nodename —————– heartbeat generates a UUID for each node
in the system as a way of uniquely identifying
a node – even if it should change nodenames.

[root@lb1 ~]# cat /etc/ha.d/authkeys ———– There are three types of authentication methods
available: crc, md5, and sha1.
This file must have mode 600.
auth 4
4 md5 MySecret —————————— MD5 is a convenient way to support a single authentication
mechanism for web, mail, LDAP, and other protocols.

[root@lb1 ~]# cat /etc/ha.d/haresources —— The haresorces file is called when heartbeat starts
This file is containing Master Node & VIP. This is common For both node.
lb1.blackpost.net IPaddr::10.11.1.70/24/eth0