shell> yum install -y net-snmp.x86_64 net-snmp-devel.x86_64
shell> tar xvf keepalived-1.2.9.tar.gz
shell> cd keepalived-1.2.9
shell> ./configure --prefix=/usr/local/keepalived --enable-snmp --sysconfdir=/etc
shell> make && make install
shell> cp /usr/local/keepalived/sbin/keepalived /sbin/
shell> cp /usr/local/keepalived/bin/genhash /bin/
######【master】
4.配置keepalived
shell> vim /etc/keepalived/keepalived.conf
#keepalived.conf由三部分组成:
global_defs
vrrp_instance
virtual_server
----------------------------------------------------------------
global_defs {
notification_email {
lij@ssr.com
}
notification_email_from lij@ssr.com
smtp_server lij@ssr.com
smtp_connect_timeout 30
router_id LVS_MASTER2
}
vrrp_instance VI_1 {
state MASTER #主设备
interface eth0 #eth0接口
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.10.54.151/24 dev eth0 label eth0:1
}
virtual_ipaddress {
172.16.50.254/24 dev eth1 label eth1:1
}
}
virtual_server 10.10.54.151 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
protocol TCP
real_server 172.16.50.157 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 172.16.50.159 80 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
------------------------------------------------------------
推荐阅读:
Haproxy+Keepalived搭建Weblogic高可用负载均衡集群
CentOS 6.3下Haproxy+Keepalived+Apache配置笔记
Haproxy + KeepAlived 实现WEB群集 on CentOS 6