`

nginx+keepalived

 
阅读更多
vi /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
        abc@abc.com
   }
   notification_email_from abc@abc.com
   smtp_server mail.abc.com
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_script chk_nginx {
    script "/etc/keepalived/chk_nginx.sh"
    interval 2
    weight 2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
track_script {
        chk_nginx    #监测nginx进程状态
}
    virtual_ipaddress {
        172.16.33.123
    }
}

vi /etc/keepalived/chk_nginx.sh
#!/bin/sh
# check nginx server status
NGINX=/usr/local/nginx/sbin/nginx
PORT=80

nmap localhost -p $PORT | grep "$PORT/tcp open"
if [ $? -ne 0 ];then
/etc/init.d/keepalived stop
fi

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics