Keepalived 安装与配置
[root@localhost home]# tar -zxvf keepalived-1.1.19.tar.gz
[root@localhost home]# cd keepalived-1.1.19
[root@localhost keepalived-1.1.19]# ./configure --prefix=/usr/local/keepalived
[root@localhost keepalived-1.1.19]# make && make install
[root@localhostkeepalived-1.1.19] cp/usr/local/keepalived/etc/rc.d/init.d/keepalived etc/rc.d/init.d/
[root@localhostkeepalived-1.1.19]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@localhost keepalived-1.1.19]# mkdir /etc/keepalived
[root@localhostkeepalived-1.1.19]#cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
[root@localhost keepalived-1.1.19]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/


1、修改MASTER配置文件
[root@localhost keepalived-1.1.19]# vi /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.1.20
}
}

virtual_server 192.168.1.20 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP

real_server 192.168.1.3 80 {
weight 1
SSL_GET {
url {
path /
digest ff20ad2481f97b1754ef3e12ecd3a9cc
}
url {
path /mrtg/
digest 9b3a0c85a887a256d6939da88aabd8cd
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}


real_server 192.168.1.4 80 {
weight 1
HTTP_GET {
url {
path /testurl/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
url {
path /testurl2/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
url {
path /testurl3/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

 

2、修改BACKUP配置文件

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.20
}
}

virtual_server 192.168.1.20 80 {
delay_loop 6
lb_algo rr
lb_kind NAT
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP

real_server 192.168.1.3 80 {
weight 1
SSL_GET {
url {
path /
digest ff20ad2481f97b1754ef3e12ecd3a9cc
}
url {
path /mrtg/
digest 9b3a0c85a887a256d6939da88aabd8cd
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

real_server 192.168.1.4 80 {
weight 1
HTTP_GET {
url {
path /testurl/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
url {
path /testurl2/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
url {
path /testurl3/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334d
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

 

posted on 2016-05-27 12:56  lihanbing  阅读(160)  评论(0编辑  收藏  举报