q490880 发表于 2015-8-18 16:38:38

keepalived配置文件

!Configuration File for keepalived

global_defs {
   notification_email {
   admin@michael-demo.com]#admin@michael-demo.com
   }
   #notification_email_from admin@michael-demo.com
   #smtp_server 127.0.0.1
   #smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_script chk_http_port {
                script "/opt/check_haproxy.sh"
                interval 2
                weight 2
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 99
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass 1111
    }
    virtual_ipaddress {
      192.168.2.191
    }
    track_script {
      chk_http_port
    }
}

check_haproxy.sh 文件
#######################################################
#!/bin/sh
if [ $(ps -C haproxy --no-header | wc -l) -eq 0 ]; then
#/etc/rc.d/init.d/haproxystart
haproxy -f /etc/haproxy/haproxy.cfg
fi
sleep 2
if [ $(ps -C haproxy --no-header | wc -l) -eq 0 ]; then
/etc/rc.d/init.d/keepalivedstop
fi
#########################################################

页: [1]
查看完整版本: keepalived配置文件