keepalived + LVS high-availability load balancing

1. Installation keepalived (mounted on two scheduling server)
Vim /etc/yum.repo.d/rhel.repo
[local-CDROM]
name = CDROM from local
BaseURL = File: /// mnt /
enable. 1 =
gpgcheck = 0

-Y-Kernel devel the install yum OpenSSL-devel-Popt devel
RPM -ivh /mnt/Packgets/ipvsadm-1.25-9.el6.i686.rpm
the tar zxvf keepalived-1.2.2.tar.gz -C / usr / the src /
/usr/src/keepalived-1.2.2/ CD
./configure --prefix = /-Kernel---with the dir = / usr / the src / kernels' / 2.6.32-131.0.15.el6.i686
the make the make the install &&
the chkconfig keepalived --add
the chkconfig keepalived ON
2. configuration scheduler (main: 192.168.13.95, preparation: 192.168.13.96, drift ip: 192.168.13.100) web server pool (node 1: 192.168.13.41, node 2: 192.168.13.47)
1), the primary HA scheduling server configured
CD / etc / keepalived /
CP keepalived.conf keepalived.conf.bak
VI /etc/keepalived/keepalived.conf
################# globally 33 is arranged #################
global_defs {
the router_id of the LVS_HA_R1
}
##################高可用HA的设置##############
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_route_id 1
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123123
}
virtual_ipaddress {
192.168.13.100
}
}
###################服务器池的配置######################
virtual_server 192.168.13.100 80 {
delay_loop 15
lb_algo rr
lb_kind DR
protocol TCP
real_server 192.168.13.41 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
real_server 192.168.13.41 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
}

ip_vs modprobe
lsmod | grep ip_vs
echo "modprobe ip_vs" >> / etc / rc.local
/etc/init.d/keepalived restart
chkconfig the ipvsadm OFF
ip addr Show dev eth0
2), HA configuration from the dispatch server
cd / etc / keepalived /
keepalived.conf keepalived.conf.bak cp
vi /etc/keepalived/keepalived.conf
################# global configuration ############# 33 is ####
global_defs {
the router_id of the LVS_HA_R2
}
################## HA HA provided ##############
vrrp_instance VI_1 {
SLAVE State
interface eth0
virtual_route_id. 1
priority 99
advert_int. 1
authentication {
AUTH_TYPE the PASS
AUTH_PASS 123123
}
virtual_ipaddress {
192.168.13.100
}
}
###################服务器池的配置######################
virtual_server 192.168.13.100 80 {
delay_loop 15
lb_algo rr
lb_kind DR
protocol TCP
real_server 192.168.13.41 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
real_server 192.168.13.47 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
}

ip_vs modprobe
lsmod | grep ip_vs
echo "modprobe ip_vs" >> / etc / rc.local
/etc/init.d/keepalived restart
chkconfig the ipvsadm OFF
ip addr Show dev eth0
###### set up a firewall and selinux (here test) #########
iptables -F
the setenforce 0

3. Configure Web server node (DR configuration operating mode, the following settings are made on the server node)
CD / etc / sysconfig / Network-Script /
CP the ifcfg the ifcfg-LO-LO: 0
VI-LO the ifcfg: 0
the DEVICE = LO : 0
IPADDR = 192.168.13.100
NETMASK = 255.255.255.255
ONBOOT = yes

echo "route add -host 192.168.13.100 dev lo:0" >>/etc/rc.local
route add -host 192.168.13.100 dev lo:0
ip addr show dev lo

vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2

sysctl -p
yum install -y httpd
vi /var/www/html/index.html
test page!!!!

/etc/init.d/httpd start
chkconfig httpd on
iptables -F
setenforce 0

4. Test lvs + Keepalived high availability cluster
in the client browser access 192.168.13.100, scheduling a bad server is available, at least to have a server node is good.
By / var / log / message log files, tracking the failover process. Use ipvsadm -Ln view LVS.

Guess you like

Origin blog.51cto.com/14380057/2408383