tcp端口监控

[root@lvs-fullnat-one keepalived]# cat keepalived.conf 
! Configuration File for keepalived
global_defs {
   notification_email {
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

local_address_group laddr_g1 {
  #172.16.98.11
  172.16.98.10
}

virtual_server_group shanks1 {
  2.2.2.3 80
}

virtual_server 2.2.2.3 80 {
    delay_loop 6
    lb_algo rr
    lb_kind FNAT
    protocol TCP
    syn_proxy
    laddr_group_name laddr_g1    #local address group
    #alpha
    #omega
    #quorum 1
    #hysteresis 0
    #quorum_up " ip addr add 10.255.255.123/32 dev lo;"    #add
    #quorum_down "ip addr del 10.255.255.123/32 dev lo;"    #del vip
    real_server 172.16.97.30 80 {
        weight 100
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

include /etc/keepalived/hosts/*.conf

[root@lvs-fullnat-one keepalived]# 

http和https

[root@lvs-fullnat-one keepalived]# cat hosts/gs-lvs-http_1.conf 
global_defs {
   notification_email {
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

local_address_group laddr_g1 {
  #172.16.98.11
  172.16.98.10
}

virtual_server_group shanks1 {
  2.2.2.4 80
}

virtual_server 2.2.2.4 443 {
    delay_loop 6
    lb_algo rr 
    lb_kind FNAT
    persistence_timeout 50
    protocol TCP
    syn_proxy
    laddr_group_name laddr_g1    #local address group

    real_server 172.16.97.31 443 {
        weight 1
        SSL_GET {
            url {
        path /lvsheartbeat/heartbeat.gif
                digest 28d6814f309ea289f847c69cf91194c6
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 2.2.2.4 80 {
    delay_loop 6
    lb_algo rr 
    lb_kind FNAT
    persistence_timeout 50
    protocol TCP
    syn_proxy
    laddr_group_name laddr_g1    #local address group

    real_server 172.16.97.31 80 {
        weight 1
        HTTP_GET {
            url { 
            path /lvsheartbeat/heartbeat.gif
            digest 28d6814f309ea289f847c69cf91194c6
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

[root@lvs-fullnat-one keepalived]# 
digest值的获取方法:
[root@BJ-device ~]# genhash -s 192.168.136.22 -p 80 -u /lvsheartbeat/heartbeat.gif
MD5SUM = 196d8fedbb521fdf05f94ee1805b51cf

lvs fullnat+ECMP【6】keepalived配置_第1张图片
微信公众号,随便发点有意思的东西