lb_algo rr lb_kind DR
persistence_timeout 60 protocol TCP
real_server 124.238.253.188 80 { weight 1 TCP_CHECK {
connect_timeout 15 nb_get_retry 3
delay_before_retry 3 connect_port 80 } }
real_server 124.238.253.155 80 { weight 1 TCP_CHECK {
connect_timeout 15 nb_get_retry 3
delay_before_retry 3 connect_port 80 } } }
Lvs2的配置文件 /usr/local/etc/keepalived/keepalived.conf global_defs {
router_id LVS_DEVEL }
vrrp_instance VI_1 { state BACKUP interface eth1
virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 }
virtual_ipaddress {
124.238.253.100 } }
vrrp_instance VI_2 { state MASTER interface eth1
virtual_router_id 52 priority 200 advert_int 1 authentication { auth_type PASS auth_pass 1111 }
virtual_ipaddress { 124.238.253.101 } }
#小频道
virtual_server 124.238.253.100 80 { delay_loop 6 lb_algo rr lb_kind DR
persistence_timeout 60 protocol TCP
real_server 124.238.253.188 80 { weight 1 TCP_CHECK {
connect_timeout 10 nb_get_retry 3
delay_before_retry 3 connect_port 80 } }
real_server 124.238.253.155 80 { weight 1 TCP_CHECK {
connect_timeout 10 nb_get_retry 3
delay_before_retry 3 connect_port 80
} } }
virtual_server 124.238.253.101 80 { delay_loop 6 lb_algo rr lb_kind DR
persistence_timeout 60 protocol TCP
real_server 124.238.253.188 80 { weight 1 TCP_CHECK {
connect_timeout 10 nb_get_retry 3
delay_before_retry 3 connect_port 80 } }
real_server 124.238.253.155 80 { weight 1 TCP_CHECK {
connect_timeout 15 nb_get_retry 3
delay_before_retry 3 connect_port 80 } } }
2.3.2 后台真实服务器虚拟地址配置:
在小频道真实服务器 124.238.253.155/124.238.253.188 执行如下脚本 #/home/tools/lvs.sh start Lvs.sh 脚本内容: #!/bin/bash
#description:start realserver #chkconfig 235 26 26
VIP1=124.238.253.100
VIP2=124.238.253.101 /etc/rc.d/init.d/functions case \start)
echo \
/sbin/ifconfig lo:0 $VIP1 broadcast $VIP1 netmask 255.255.255.255 up /sbin/ifconfig lo:1 $VIP2 broadcast $VIP2 netmask 255.255.255.255 up echo \echo \echo \echo \;; stop)
/sbin/ifconfig lo:0 down /sbin/ifconfig lo:1 down
echo \
echo \echo \echo \echo \;; *)
echo \exit 1 esac
# shell end
3 第三部分:应用管理:
3.1 启动/关闭lvs调度器:
启动lvs
#/usr/local/sbin/keepalived –D -f /usr/local/etc/keepalived/keepalived.conf 关闭lvs
# killall -9 keepalived;ipvsadm -C
3.2 系统虚拟IP管理:
查看虚拟IP地址 # ip address list 删除虚拟IP地址