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