[lvs]lvs的三種模式

回顧了下lvs的三種模式的調度機制
1.lvs的dr模式中的arp的抑制,eth用本身口arp迴應.
2.keepalive是否直接操做rs? 不直接操做, 只操做dr(配lvs)
3.tunnel模式keepalive怎麼配置?
4.lvs支持的wrr,rr動態調整?html

lvs的三種模式和調度機制

http://www.cnblogs.com/f-ck-need-u/p/8451982.html
https://www.cnblogs.com/edisonchou/p/4281978.html算法

dr模式圖

網絡

tunnel模式圖
oop

三種模式對比
code

keepalive高可用(vip+rsip)

1,配置lvs
2,實現vip的漂移(vrrp)router

dr模式實驗
server

手動配置rs: 思路: 手動綁定vip到rs, 而dr的vip不須要手動配置,ka搞定htm

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主的配置blog

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)ip

# 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
相關文章
相關標籤/搜索