LVS+keepalived 高可用性配置
kevin.Zhu 发布于:2013-1-16 16:49 分类:架构设计 有 16 人浏览,获得评论 0 条
4台机器, 两台LVS机器通过Keepalived做HA。 两台Web机器
机器信息:
debian: 192.168.0.186 (LVS)
centos:192.168.0.188 (LVS)
debian: 192.168.0.183 (web)
debian: 192.168.0.190 (web)
============
组LVS
两台调度机配置:
centos: yum -y install ipvsadm
debian: apt-get install ipvsadm
ifconfig eth0:0 192.168.0.251 broadcast 192.168.0.255 netmask 255.255.255.0
route add -host 192.168.0.251 dev eth0:0
#配置转发 /etc/sysctrl.conf , net.ipv4.ip_forward=1
ipvsadm –C
ipvsadm -A -t 192.168.0.251:80
ipvsadm -a -t 192.168.0.251:80 -r 192.168.0.190 -w 3
ipvsadm -a -t 192.168.1.251:80 -r 192.168.0.183 -w 3
两台WEB真实机配置:
ifconfig lo:0 192.168.0.251 broadcast 192.168.0.251 netmask 255.255.255.255
#arp抑制
net.ipv4.ip_forward=1
net.ipv4.conf.lo.arp_ignore=1
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
============== 以上LVS 配置完成 ===============
==================
两台LVS机器用keepalived 组HA
安装keepalived . debian系统可以apt安装
主、从机的 /etc/keepalived/keepalived.conf 配置文件 大致如下:
! Configuration File for keepalived
global_defs {
notification_email {
bigbenz8@hotmail.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 111111
}
virtual_ipaddress {
192.168.0.251
}
}
virtual_server 192.168.0.251 80{
delay_loop 3
lb_algo wlc
lb_kind DR
persistence_timeout 1200
protocol TCP
ha_suspend
real_server 192.168.0.183 80{
weight 3
TCP_CHECK {
connect_timeout 3
}
}
real_server 192.168.0.190 80{
weight 3
TCP_CHECK {
connect_timeout 3
}
}
}
================= 以上HA配置完成 ============