码迷,mamicode.com
首页 > 其他好文 > 详细

keepalived.sh

时间:2016-08-30 19:47:27      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

1.keepalived.conf主

! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   vrrp_strict
}

#脚本监测
  vrrp_script chk_http_port {
    script "/etc/keepalived/chk_keepalived.sh"
    #每2s检测一次,优先级减5,检测2次才算失败,检测1次成功就算成功
    interval 2
    weight -5
    fall 2
    rise 1
}
vrrp_instance VI_1 {
    state MASTER
    interface eth1
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }

#执行监控服务
  track_script {
    chk_http_port
}

    virtual_ipaddress {
        172.16.1.30/24
    }
}

keepalived.conf备

 

 

2.

[root@proxy01 ~]# vim /etc/keepalived/chk_keepalived.sh 
#!/bin/sh

nginxpid=`ps -C mysql-proxy --no-header |wc -l`
if [ $nginxpid -eq 0 ];then
        /etc/init.d/mysql-proxy start
  sleep 3
        if [ `ps -C mysql-proxy --no-header |wc -l` -eq 0 ];then
            /etc/init.d/keepalived stop
        fi
fi

 

keepalived.sh

标签:

原文地址:http://www.cnblogs.com/sunmmi/p/5805219.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!