6、keepalived+lvs实现调度、高可用、高性能集群
Keepalived的作用是:
检
测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web服务器从系统中剔除,当web服
务器工作正常后Keepalived自动将web服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的web服务
器
(1)安装keepalived
# ./configure --prefix=/usr/local/keepalived --enable-snmp --enable-profile --with-kernel-version=2.6 --sysconfdir=/etc
# make && make install
(2)配置keepalived
# cd /etc/keepalived
# vim keepalived.conf
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id lvs-s1
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 30
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass aixocm
}
virtual_ipaddress {
172.16.10.10/24 dev eth0
}
}
virtual_server 172.16.10.10 80 {
delay_loop 3
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 60
protocol TCP
real_server 172.16.20.20 80 {
weight 2
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 172.16.20.30 80 {
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
# vim /etc/sysconfig/keepalived
KEEPALIVED_OPTIONS="-D -f /etc/keepalived/keepalived.conf"