keepalived high availability, monitoring web server status

 

1. Keepalived high availability, monitoring web server status

4.1 Install two machines, one group and one cluster

 

yum install -y keepalived

 

Main machine configuration, virtual ip is: 192.168.1.100

vrrp_instance VI_1 {
    state MASTER # BACKUP on the standby server
    interface eth0
    virtual_router_id 51
    priority 100 #90 on the standby server
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.100
    }
}
 
virtual_server 192.168.1.100 80 {
    delay_loop 6 # Query Realserver status every 6 seconds
    lb_algo rr #lvs algorithm
    lb_kind DR   # Direct Route
    persistence_timeout 0 # The same IP link is assigned to the same realserver within 60 seconds
    protocol TCP #Check realserver status with tcp protocol
 
    real_server 192.168.1.27 80{
        weight 100
        TCP_CHECK {
            connect_timeout 10 #10 seconds no response timeout
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
 
    real_server 192.168.1.28 80{
        weight 100
        TCP_CHECK {
            connect_timeout 10 #10 seconds no response timeout
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

 

keepalived from the machine

 

vrrp_instance VI_1 {
    state BACKUP # BACKUP on the standby server
    interface eth0
    virtual_router_id 51
    priority 90 #90 on the standby server
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.100
    }
}
 
virtual_server 192.168.1.100 80 {
    delay_loop 6 # Query Realserver status every 6 seconds
    lb_algo rr #lvs algorithm
    lb_kind DR   # Direct Route
    persistence_timeout 0 # The same IP link is assigned to the same realserver within 60 seconds
    protocol TCP #Check realserver status with tcp protocol
 
    real_server 192.168.1.27 80{
        weight 100
        TCP_CHECK {
            connect_timeout 10 #10 seconds no response timeout
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
 
    real_server 192.168.1.28 80{
        weight 100
        TCP_CHECK {
            connect_timeout 10 #10 seconds no response timeout
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

 

Start the keepalived service on the primary and standby machines

/etc/init.d/keepalived start

 

View port forwarding rules

ipvsadm -ln

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326445151&siteId=291194637