Lvs+keepalived实现负载均衡、故障剔除(DR模式)
http://shansren.blog.运维网.com/attachment/200910/200910221256183567421.jpgNode1: 192.168.1.253
Node2: 192.168.1.254
VIP: 192.168.1.250
环境 centos5.2(我这里是用两台机实现的)
1、安装ipvsadm
yum -y install ipvsadm
2、安装keepalived
# wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz
# tar zxvf keepalived-1.1.15.tar.gz
# cd keepalived-1.1.15
# ./configure --prefix=/ --mandir=/usr/local/share/man/ --with-kernel-dir=/usr/src/kernels/2.6.18-92.el5-i686/
configure后会输入这结果为正确
Keepalived configuration
------------------------
Keepalived version : 1.1.15
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes #支持lvs
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use LinkWatch : No
Use Debug flags : No
# make && make install
到此,lvs+keepalived安装完成。但是还不能使用lvs功能,接下来以dr模式配置lvs+keepalived
3、# cd /etc/keepalived/
# vim keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
shanswei@gmail.com
}
notification_email_fromshanswei@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER ##主lvs设置成master
interface eth0
virtual_router_id 51
priority 102 ##从lvs设置成 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.250 ## 如多个vip,继续换行填写。
}
}
virtual_server 192.168.1.250 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.1.253 80 {
weight 3
TCP_CHECK {
connect_port 80
connect_timeout 30
}
}
real_server 192.168.1.254 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 30
}
}
好了,keepalived配置完成了。
启动keepalived
页:
[1]