IT虾米网

keeplived高可用配置详解

flyfish 2021年09月18日 程序员 255 0
本文章主要介绍了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 } } }

发布评论
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

nginx访问权限问题详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。