High Availability--keepalived詳解篇(二)之keepalive配置詳解

本配置項是針對Keepalived v1.3.4 (02/18,2017):

#######################全局配置#################################


global_defs {
   notification_email {  #指定keepalived在發生切換時需要發送email到的對象,一行一個
    [email protected]
   }
   notification_email_from [email protected] #指定發件人
   smtp_server localhost #指定smtp服務器地址
   smtp_connect_timeout 30 #指定smtp連接超時時間
   router_id LVS_DEVEL #運行keepalived機器的一個標識
}

keyworkddefinitiontype
global_defs identify the global def configuration block(全局配置)
notification_email email accounts that will receive the notification mail(收件人的電子郵件)List(列表)
notification_email_from email to use when processing “MAIL FROM:” SMTP command(發件人的電子郵件)List
smtp_server remote SMTP server to use for sending mail notifications(smtp服務器)alphanum(字母數字)
smtp_connection_timeout specify a timeout for SMTP stream processing(指定smtp連接超時時間)numerical
lvs_id

specify the name of the LVS director

(指定LVS控制器的名稱)

alphanum




############vrrp監控組實例###############
vrrp_sync_group string {

group {
string(實例名)
string
}
notify_master /path_to_script/script_master.sh
(or notify_master “/path_to_script/script_master.sh <arg_list>”)
notify_backup /path_to_script/script_backup.sh
(or notify_backup “/path_to_script/script_backup.sh <arg_list>”)
notify_fault /path_to_script/script_fault.sh
(or notify_fault “/path_to_script/script_fault.sh <arg_list>”)
}

notify_master:當keepalive狀態爲master的時候觸動腳本

notify_backup:當keepalive狀態是backup的時候觸動腳本

notify_fault: 當keepalive狀態失敗的時候

#用vrrp_sync_group 統一監控的目的是,如果你有多個實例,一個內網段和一個外網段,當你外網端ok的時候,內網段有問題,vrrp_sync_group還是會切


vrrp_instance string {
state MASTER|BACKUP (實例狀態)
interface string (心跳接口)
mcast_src_ip @IP (組播源ip,默認是心跳接口ip)
lvs_sync_daemon_interface string (指定的網絡接口lv sync_daemon上運行,默認是心跳接口
virtual_router_id num (設置虛擬路由ID)
priority num (優先級)
advert_int num (間隔探測時間,默認1s)

smtp_alert (觸發smtp)
authentication {
auth_type PASS|AH(認證類型)
auth_pass string (認證密碼)
}

########################跟蹤腳本#########

track_script {

    chk_httpd


}


  track_interface { (追蹤接口,除了默認的心跳口)

   eth0

}

virtual_ipaddress { # Block limited to 20 IP addresses(限制20個以內)

@IP(虛擬ip)
@IP
@IP
}
virtual_ipaddress_excluded { # Unlimited IP addresses number(不限制ip地址)
@IP(虛擬ip)
@IP
@IP
}
notify_master /path_to_script/script_master.sh (同上)
(or notify_master “/path_to_script/script_master.sh <arg_list>”)
notify_backup /path_to_script/script_backup.sh
(or notify_backup “/path_to_script/script_backup.sh <arg_list>”)
notify_fault /path_to_script/script_fault.sh
(or notify_fault “/path_to_script/script_fault.sh <arg_list>”)
}

#########腳本檢測#############

vrrp_script chk_httpd {

    script "/etc/keepalived/check_httpd.sh"

    interval 1 (間隔1秒)

    weight 2 (權重,這個地方需要在後面的文章詳細介紹一下)

    fall 2 (需要請求2次失敗,才叫失敗,默認是1)

    rise 2 (需要請求2次成功,才叫成功默認1,備註這個參數測試好像不行)

}

#######LVS#######################

virtual_server (@IP PORT)|(fwmark num) {
delay_loop num(指定間隔檢測時間)
lb_algo rr|wrr|lc|wlc|sh|dh|lblc(調度算法)
lb_kind NAT|DR|TUN(lvs模式)
(nat_mask @IP)
persistence_timeout num (會話保持時間)
persistence_granularity @IP (?)
virtualhost string (指定http虛擬頭部)
protocol TCP|UDP (指定協議)
sorry_server @IP PORT (指定備用vs地址)
real_server @IP PORT {
weight num (權重)
########tcp探測#######

TCP_CHECK {
connect_port num (連接端口)
connect_timeout num (超時時間)
}
}
real_server @IP PORT {
weight num

##########混合探測#####
MISC_CHECK {
misc_path /path_to_script/script.sh(腳本檢測)
(or misc_path “/path_to_script/script.sh <arg_list>”)
}
}
}
real_server @IP PORT {
weight num

#####http和https檢測#####
HTTP_GET|SSL_GET {
url { # You can add multiple url block
path alphanum

status num (狀態檢測)
digest alphanum (genhash,頁面hash)
}
connect_port num
connect_timeout num
nb_get_retry num
delay_before_retry num
}
}
}




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