测试环境拓扑
LVS+Keepalived前端调度
Master
系统版本:CentOS release 5.9 (Final)
内核版本:2.6.18-348.3.1.el5
安装配置
1.安装ipvsadm组件
#yum install –y ipvsadm
2.安装编译环境:
#yuminstall -y kernel-devel gcc openssl-devel
3.解压、编译、安装
# tar -zxvf keepalived-1.2.7.tar.gz
#cd keepalived-1.2.7
#./configure--sysconf=/etc
#make && makeinstall
4.启动服务
#ln -s/usr/local/sbin/keepalived /sbin/
#cp/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
#/etc/init.d/keepalivedstart
#ln -s/etc/init.d/keepalived /etc/rc.d/rc3.d/S99keepalived
#ln -s/etc/init.d/keepalived /etc/rc.d/rc5.d/S99keepalived
5.配置
# vim/etc/keepalived/keepalived.conf
编辑如下:
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.12.100
}
}
virtual_server192.168.12.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 192.168.12.220 80 {
weight 1
connect_timeout 3
nb_get_retry 3
connect_port 80
delay_before_retry 3
}
real_server 192.168.12.221 80 {
weight 2
connect_timeout 3
nb_get_retry 3
connect_port 80
delay_before_retry 3
}
}
6.重启服务
#service keepalivedrestart
7.查看
#ipvsadm –L –n
结果如图:
Keepalived 的详细介绍:请点这里
Keepalived 的下载地址:请点这里
推荐阅读:
CentOS 6.3下Haproxy+Keepalived+Apache配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm
Haproxy + KeepAlived 实现WEB群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm
Keepalived+Haproxy配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm
Haproxy+Keepalived构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm