首页 > 代码库 > keepalived.sh

keepalived.sh

1.keepalived.conf主

! Configuration File for keepalivedglobal_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/shnginxpid=`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        fifi

 

keepalived.sh