keepalived实现LB配置

Posted golinux

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了keepalived实现LB配置相关的知识,希望对你有一定的参考价值。

vim /etc/keepalived/keeplived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.17.205
    }
}
# 虚拟服务器ip和port,用于分发请求
virtual_server 192.168.17.205 80 {
    delay_loop 6
    # lvs调度算法 rr|wrr|lc|wlc|lblc|sh|dh
    lb_algo wrr 
    # lvs转发方法
    lb_kind DR
    #persistence_timeout 50
    protocol TCP

    # 真实服务器ip和port
    real_server 192.168.17.101 80 {
        # 权重
        weight 1
        # 健康检查
        TCP_CHECK {
            # 连接超时时间,默认5s,
            connect_timeout 3
            # 重新连接次数
            nb_get_retry 3
            # 重新尝试连接前延迟3s
            delay_before_retry 3
            # 真实服务器port
            connect_port 80
        }
    }

    real_server 192.168.17.103 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

 

以上是关于keepalived实现LB配置的主要内容,如果未能解决你的问题,请参考以下文章

全站 https搭建discuz并实现lb01和lb02keepalived高可用故障转移

LB集群之LVS/keepalived

Keepalived 双实例双主模式配置

keepalived weight正负值问题(实现主服务器nginx故障后迅速切换到备服务器)

Keepalived 配置

keepalived实战