keeplived高可用配置详解程序员

本文章主要介绍了keeplived高可用配置,具有不错的的参考价值,希望对您有所帮助,如解说有误或未考虑完全的地方,请您留言指出,谢谢!

前提:关闭防火墙,关闭selinux

1、主备配置

vim keeplived-lb01.conf

global_defs { router_id LVS_01 } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id
51 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.0.0.3/24 } } virtual_server 10.0.0.3 80 { delay_loop 6 lb_algo wrr lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 10.0.0.7 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 10.0.0.8 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }


vim keeplived-lb02.conf

global_defs { router_id LVS_02 } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id
51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.0.0.3/24 } } virtual_server 10.0.0.3 80 { delay_loop 6 lb_algo wrr lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 10.0.0.7 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 10.0.0.8 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }

2、互为主备配置

vim keeplived-lb01.conf 
 
global_defs { 
   router_id LVS_01 
} 
 
vrrp_instance VI_1 { 
    state MASTER 
    interface eth0 
    virtual_router_id 51 
    priority 150 
    advert_int 1 
    authentication { 
        auth_type PASS 
        auth_pass 1111 
    } 
    virtual_ipaddress { 
     10.0.0.3/24 
    } 
} 
 
vrrp_instance VI_2 { 
    state BACKUP 
    interface eth0 
    virtual_router_id 52 
    priority 100 
    advert_int 1 
    authentication { 
        auth_type PASS 
        auth_pass 2222 
    } 
    virtual_ipaddress { 
     10.0.0.4/24 
    } 
} 
 
 
 
virtual_server 10.0.0.3 80 { 
    delay_loop 6               
    lb_algo wrr                 
    lb_kind DR                 
    nat_mask 255.255.255.0 
    persistence_timeout 50      
    protocol TCP                 
 
    real_server 10.0.0.7 80 { 
        weight 1               
        TCP_CHECK { 
        connect_timeout 8        
        nb_get_retry 3 
        delay_before_retry 3 
        connect_port 80 
        } 
    } 
 
    real_server 10.0.0.8 80 { 
        weight 1               
        TCP_CHECK { 
        connect_timeout 8        
        nb_get_retry 3 
        delay_before_retry 3 
        connect_port 80 
        } 
    } 
} 
 
 
virtual_server 10.0.0.4 80 { 
    delay_loop 6           
    lb_algo wrr                 
    lb_kind DR                 
    nat_mask 255.255.255.0 
    persistence_timeout 50      
    protocol TCP                 
 
    real_server 10.0.0.7 80 { 
        weight 1               
        TCP_CHECK { 
        connect_timeout 8        
        nb_get_retry 3 
        delay_before_retry 3 
        connect_port 80 
        } 
    } 
 
    real_server 10.0.0.8 80 { 
        weight 1               
        TCP_CHECK { 
        connect_timeout 8        
        nb_get_retry 3 
        delay_before_retry 3 
        connect_port 80 
        } 
    } 
}


vim keeplived-lb02.conf

global_defs { router_id LVS_02 } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id
51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.0.0.3/24 } } vrrp_instance VI_2 { state MASTER interface eth0 virtual_router_id 52 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 2222 } virtual_ipaddress { 10.0.0.4/24 } } virtual_server 10.0.0.3 80 { delay_loop 6 lb_algo wrr lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 10.0.0.7 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 10.0.0.8 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } } virtual_server 10.0.0.4 80 { delay_loop 6 lb_algo wrr lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 protocol TCP real_server 10.0.0.7 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 10.0.0.8 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }

原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/228367.html

(0)
上一篇 2022年1月11日
下一篇 2022年1月11日

相关推荐

发表回复

登录后才能评论