Handling nginx Failover With KeepAlived

Handling nginx Failover With KeepAlived

by Vivek Gite on February 25, 2010 ・ 3 comments
How do configure to release and obtain VIP (virtual IP) when nginx is dead, down or system is rebooted for the kernel upgrades?

Edit /usr/local/etc/keepalived/keepalived.conf and add the following section to check whether nginx is alive or dead:
# vi /usr/local/etc/keepalived/keepalived.conf
Updated file on both lb0 and lb1:
vrrp_script chk_http_port {
        script "/usr/bin/killall -0 nginx"
        interval 2
        weight 2
}
vrrp_instance VI_1 {
        interface eth0
        state MASTER
        virtual_router_id 51
        priority 101
        authentication {
            auth_type PASS
            auth_pass Add-Your-Password-Here
        }
        track_script {
            chk_http_port
        }
        virtual_ipaddress {
                202.54.1.1/29 dev eth1
        }
}
 
Save and close the file. Reload keealived:
# /etc/init.d/keepalived restart
If nginx died due to any issues keepalived will release master VIP and backup server will become active. When master nginx LB0 comes backs online, the backup LB1 will go down in backup state.
This FAQ entry is 3 of 7 in the " CentOS / RHEL nginx Reverse Proxy Tutorial" series. Keep reading the rest of the series:
 

你可能感兴趣的:(高可用,keepalived,职场,休闲)