centos下 keepalived1.2.8配置文件

一、軟件配置文件

vrrp_script chk_http_port {
script "/etc/keepalived/nginx_pid.sh"
interval 2
weight 2
}
global_defs {
        notification_email {
              [email protected]
        }
        notification_email_from [email protected]
        smtp_server smtp.exmail.qq.com
        smtp_connect_timeout 30
        router_id LVS_Twioo
}
vrrp_instance VI_1 {
        state BACKUP
        interface eth0
        virtual_router_id 51
        mcast_src_ip 192.168.2.251
        priority 80
        advert_int 1
        smtp_alert
        authentication {
                auth_type   PASS
                auth_pass 123456
}
virtual_ipaddress {
                192.168.2.88
        }
track_script {
   chk_http_port
}

}

virtual_server 192.168.2.88 80 {
   delay_loop 6
   lb_algo rr
   lb_kind DR
   persistence_timeout 5
   protocol TCP

   real_server 192.168.2.251 80 {
       weight 3
       TCP_CHECK {
           connect_timeout 10
           nb_get_retry 3
           delay_before_retry 3
           connect_port 80
       }
   }
   real_server 192.168.2.80 80 {
       weight 3
       TCP_CHECK {
           connect_timeout 3
           nb_get_retry 3
           delay_before_retry 3
           connect_port 80
       }
   }
}

二、檢測nginx是否正常檢測文件


#!/bin/bash

nginxpid=`ps -C nginx --no-header | wc -l`
if [ $nginxpid -eq 0 ];then
  eth0 $nginxpid
  /usr/local/nginx/sbin/nginx
  sleep 1
   if [ $nginxpid -eq 0 ];then
   /etc/init.d/keepalived stop
   fi
fi
sleep 1

~
~
~
~
~
~
~
~


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章