keepalived配置文件說明

這個配置文件說明,也不知道是在那個地方瞅到的,內容以下web


global_defs {算法

  notification_email {  #指定keepalived在發生切換時須要發送email到的對象,一行一個服務器

       monitor@3evip.cn負載均衡

  }ide

  notification_email_from monitor@3evip.cn #指定發件人oop

  smtp_server stmp.3evip.cn #指定smtp服務器地址ui

  smtp_connect_timeout 30 #指定smtp鏈接超時時間url

  router_id LVS_DEVEL #運行keepalived機器的一個標識spa

}debug

 

vrrp_sync_group VG_1{ #監控多個網段的實例

   group {

       inside_network #實例名

       outside_network

   }

   notify_master /path/xx.sh #指定當切換到master時,執行的腳本

   netify_backup /path/xx.sh #指定當切換到backup時,執行的腳本

   notify_fault "path/xx.sh VG_1" #故障時執行的腳本

   notify /path/xx.sh

   smtp_alert #使用global_defs中提供的郵件地址和smtp服務器發送郵件通知

}

 

vrrp_instance inside_network {

   state BACKUP #指定那個爲master,那個爲backup,若是設置了nopreempt這個值不起做用,主備考priority決定

   interface eth0 #設置實例綁定的網卡

   dont_track_primary #忽略vrrp的interface錯誤(默認不設置)

   track_interface{ #設置額外的監控,裏面那個網卡出現問題都會切換

       eth0

       eth1

   }

   mcast_src_ip #發送多播包的地址,若是不設置默認使用綁定網卡的primary ip

   garp_master_delay #在切換到master狀態後,延遲進行gratuitous ARP請求

   virtual_router_id 50 #VPID標記

   priority 99 #優先級,高優先級競選爲master

   advert_int 1 #檢查間隔,默認1秒

   nopreempt #設置爲不搶佔 注:這個配置只能設置在backup主機上,並且這個主機優先級要比另一臺高

   preempt_delay #搶佔延時,默認5分鐘

   debug #debug級別

   authentication { #設置認證

       auth_type PASS #認證方式

       auth_pass 111111 #認證密碼

   }

   virtual_ipaddress { #設置vip

       192.168.36.200

   }

}

virtual_server 192.168.36.99 80 {

   delay_loop 6 #健康檢查時間間隔

   lb_algo rr  #lvs調度算法rr|wrr|lc|wlc|lblc|sh|dh

   lb_kind DR  #負載均衡轉發規則NAT|DR|RUN

   persistence_timeout 5 #會話保持時間

   protocol TCP #使用的協議

   persistence_granularity <NETMASK> #lvs會話保持粒度

   virtualhost <string> #檢查的web服務器的虛擬主機(host:頭)    

   sorry_server<IPADDR> <port> #備用機,全部realserver失效後啓用

   real_server 192.168.200.5 23 {

           weight 1 #默認爲1,0爲失效

           inhibit_on_failure #在服務器健康檢查失效時,將其設爲0,而不是直接從ipvs中刪除

           notify_up <string> | <quoted-string> #在檢測到server up後執行腳本

           notify_down <string> | <quoted-string> #在檢測到server down後執行腳本

           TCP_CHECK {

               connect_timeout 3 #鏈接超時時間

               nb_get_retry 3 #重連次數

               delay_before_retry 3 #重連間隔時間

               connect_port 23  健康檢查的端口的端口

               bindto <ip>  

           }

           HTTP_GET | SSL_GET{

               url{ #檢查url,能夠指定多個

                       path /

                       digest <string> #檢查後的摘要信息

                       status_code 200 #檢查的返回狀態碼

               }

               connect_port <port>

               bindto <IPADD>

               connect_timeout 5

               nb_get_retry 3

               delay_before_retry 2

           }

 

           SMTP_CHECK{

                   host{

                       connect_ip <IP ADDRESS>

                       connect_port <port> #默認檢查25端口

                       bindto <IP ADDRESS>

                   }

                   connect_timeout 5

                   retry 3

                   delay_before_retry 2

                   helo_name <string> | <quoted-string> #smtp helo請求命令參數,可選

           }

           MISC_CHECK{

                   misc_path <string> | <quoted-string> #外部腳本路徑

                   misc_timeout #腳本執行超時時間

                   misc_dynamic #如設置該項,則退出狀態碼會用來動態調整服務器的權重,返回0 正常,不修改;返回1,檢查失敗,權重改成0;返回2-255,正常,權重設置爲:返回狀態碼-2

           }

   }

}

相關文章
相關標籤/搜索