[lvs]lvs的三种模式
回顾了下lvs的三种模式的调度机制
1.lvs的dr模式中的arp的抑制,eth用自己口arp回应.
2.keepalive是否直接操作rs? 不直接操作, 只操作dr(配lvs)
3.tunnel模式keepalive怎么配置?
4.lvs支持的wrr,rr动态调整?
lvs的三种模式和调度机制
http://www.cnblogs.com/f-ck-need-u/p/8451982.html
https://www.cnblogs.com/edisonchou/p/4281978.html
dr模式图
tunnel模式图
三种模式对比
keepalive高可用(vip+rsip)
1,配置lvs
2,实现vip的漂移(vrrp)
dr模式实验
手动配置rs: 思路: 手动绑定vip到rs, 而dr的vip不需要手动配置,ka搞定
SNS_VIP=192.168.80.200
/etc/rc.d/init.d/functions
case "$1" in
start)
ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP
/sbin/route add -host $SNS_VIP dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p >/dev/null 2>&1
echo "RealServer Start OK"
;;
stop)
ifconfig lo:0 down
route del $SNS_VIP >/dev/null 2>&1
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
echo "RealServer Stoped"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
keepalive主的配置
global_defs {
notification_email {
edisonchou@hotmail.com
}
notification_email_from sns-lvs@gmail.com
smtp_server 192.168.80.1
smtp_connection_timeout 30
router_id LVS_DEVEL # 设置lvs的id,在一个网络内应该是唯一的
}
vrrp_instance VI_1 {
state MASTER #指定Keepalived的角色,MASTER为主,BACKUP为备
interface eth1 #指定Keepalived的角色,MASTER为主,BACKUP为备
virtual_router_id 51 #虚拟路由编号,主备要一致
priority 100 #定义优先级,数字越大,优先级越高,主DR必须大于备用DR
advert_int 1 #检查间隔,默认为1s
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.80.200 #定义虚拟IP(VIP)为192.168.2.33,可多设,每行一个
}
}
# 定义对外提供服务的LVS的VIP以及port
virtual_server 192.168.80.200 80 {
delay_loop 6 # 设置健康检查时间,单位是秒
lb_algo wrr # 设置负载调度的算法为wlc
lb_kind DR # 设置LVS实现负载的机制,有NAT、TUN、DR三个模式
nat_mask 255.255.255.0
persistence_timeout 0
protocol TCP
real_server 192.168.80.102 80 { # 指定real server1的IP地址
weight 3 # 配置节点权值,数字越大权重越高
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.80.103 80 { # 指定real server2的IP地址
weight 3 # 配置节点权值,数字越大权重越高
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
另一个tunnel实验附: lvs的tunnel模式rs的一段配置(看他手动配了tun0)
# ifconfig tunl0 10.6.2.195 broadcast 10.6.2.195 netmask 255.255.255.255 up
# route add -host 10.6.2.195 dev tunl0
# echo "0" > /proc/sys/net/ipv4/ip_forward
# echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
# echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
# echo 0 > /proc/sys/net/ipv4/conf/tunl0/rp_filter
# echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter