負載均衡實現故障vip自動漂移


環境說明演示vip自動漂移
192.168.237.50
192.168.237.51
vip: 192.168.237.5

keepalived開源軟件實現
keepalived可以實現當vip掛的時候,自動漂移,基於vrrp虛擬路由冗余協議
主備,vrrp去宣告


keepalived主服務器的配置/usr/local/keepalived/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 2
    authentication {
        auth_type PASS
        auth_pass 666666
    }
    virtual_ipaddress {
        192.168.237.5/24
    }
}


vrrp_instance配置,配置vip
state 配置主或者備
interface 配置vip使用的物理網卡
virtual_router_id 虛擬路由id
priority 權重配置,主的權重比備的高
advert_int 主每2s發個vrrp包,說明自己正常
authentication 認證信息
virtual_ipaddress 配置vip


檢查配置,啟動keepalived
/usr/local/keepalived/sbin/keepalived -t -f /usr/local/keepalived/etc/keepalived/keepalived.conf
/usr/local/keepalived/sbin/keepalived -f /usr/local/keepalived/etc/keepalived/keepalived.conf


keepalived備服務器的配置/usr/local/keepalived/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 99
    advert_int 2
    authentication {
        auth_type PASS
        auth_pass 666666
    }
    virtual_ipaddress {
        192.168.237.5/24
    }
}


抓包可以看到vrrp協議


驗證keepalived的vip自動漂移

存在問題
主起來后又會接管vip
vip的頻繁漂移對於我們不太有利


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM