keepalived配置lvs

发布于 2025-03-03  117 次阅读


! Configuration File for keepalived

global_defs {
   router_id lvs-keepalived-backup    #辅助改为lvs-backup
}

vrrp_instance VI_1 {
    state BACKUP
    interface ens33                #VIP绑定接口
    virtual_router_id 80         #VRID 同一组集群,主备一致          
    priority 50            #本节点优先级,辅助改为50
    advert_int 1            #检查间隔,默认为1s
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        11.1.1.144/24  # 可以写多个vip
    }
}

virtual_server 11.1.1.144 80 {    #LVS配置
        delay_loop 3
        lb_algo rr     #LVS调度算法
        lb_kind DR     #LVS集群模式(路由模式)
        net_mask 255.255.255.0
        protocol TCP      #健康检查使用的协议
        sorry_server 11.1.1.146
        real_server 11.1.1.140 80 {
                weight 1
                inhibit_on_failure   #当该节点失败时,把权重设置为0,而不是从IPVS中删除
                #TCP_CHECK {          #健康检查
                #       connect_port 80   #检查的端口
                #       connect_timeout 3  #连接超时的时间
                #       }
                HTTP_GET{
        url {
                path /index.html
                digest 676190fd270b3cbc282da2a5de7b3cce
        }
        connect_port 80
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 2
}
                }
        real_server 11.1.1.142 80 {
                weight 1
                inhibit_on_failure
                HTTP_GET{
        url {
                path /index.html
                digest f843537b8f77a0de810473a812a19256
        }
        connect_port 80
        connect_timeout 3
        nb_get_retry 3
        delay_before_retry 2
}
                        }
                }
}
届ける言葉を今は育ててる
最后更新于 2025-03-03