码迷,mamicode.com
首页 > 其他好文 > 详细

keepalived主备模式

时间:2020-06-18 10:52:30      阅读:45      评论:0      收藏:0      [点我收藏+]

标签:com   ati   interval   global   配置   script   pad   smtp   模式   

主节点ip:192.168.3.122,备节点ip:192.168.3.123

主节点配置如下:

! Configuration file for keepalived
global_defs {
   notification_email {
    admin@wf.com
        }
   notification_email_from admin@wf.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
#监控huawei-grpc
vrrp_script chk_nginx {
    script "/etc/keepalived/script/monitor_nginx.sh"
    interval 2
    weight 2
}

vrrp_instance VI_1 {
    state MASTER  #主从设置
    interface em1  #网卡名
    virtual_router_id 1
    mcast_src_ip 192.168.3.122 #本机ip
    priority 100  #从机小于主机
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass chtopnet
    }
    virtual_ipaddress {
        192.168.3.120  #VIP 的IP
    }
    #track_script {
    #chk_nginx
    #}

}

virtual_server 192.168.3.120 50051 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP

    real_server 192.168.3.122 50051 {
        weight 3
        TCP_CHECK {
            connect_timeout 10
            retry 3
            delay_before_retry 3
            connect_port 50051
        }
    }
 real_server 192.168.3.123 50051 {
        weight 3
        TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 50051
        }
    }
}

备节点配置如下:

! Configuration file for keepalived
global_defs {
   notification_email {
    admin@wf.com
        }
   notification_email_from admin@wf.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
#监控huawei-grpc
vrrp_script chk_nginx {
    script "/etc/keepalived/script/monitor_nginx.sh"
    interval 2
    weight 2
}

vrrp_instance VI_1 {
    state BACKUP  #主从设置
    interface em1  #网卡名
    virtual_router_id 1
    mcast_src_ip 192.168.3.123 #本机ip
    priority 50  #从机小于主机
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass chtopnet
    }
    virtual_ipaddress {
        192.168.3.120  #VIP 的IP
    }
    #track_script {
    #chk_nginx
    #}

}

virtual_server 192.168.3.120 50051 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP

    real_server 192.168.3.122 50051 {
        weight 3
        TCP_CHECK {
            connect_timeout 10
            retry 3
            delay_before_retry 3
            connect_port 50051
        }
    }
 real_server 192.168.3.123 50051 {
        weight 3
        TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 50051
        }
    }
}

keepalived主备模式

标签:com   ati   interval   global   配置   script   pad   smtp   模式   

原文地址:https://blog.51cto.com/204222/2505328

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!