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
        }
    }
}

 

posted @ 2019-12-01 17:40  sxlong_work  阅读(925)  评论(0编辑  收藏  举报