Keepalived_vrrp: Unable to access script `[[`

在Centos 7中配置如下:

yum install keepalive -y
版本:
Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

vrrp_script chk_down {
script"[[ -f /etc/keepalived/down ]] && exit 1 || exit 0"
interval 1
weight -2
}

track_script {
chk_down
}

touch /etc/keepalived/down #無法手動切換主從

查看日誌
Keepalived_vrrp[9772]: Unable to access script [[
Dec 5 05:06:18 node71 Keepalived_vrrp[9772]: Disabling track script chk_down since not found

解決:
vrrp_script chk_down {
#script "[[ -f /etc/keepalived/down ]] && exit 1 || exit 0"
script "/etc/keepalived/keep_down.sh"
interval 1
}

cat etc/keepalived/keep_down.sh
#!/bin/bash
if [ -f /etc/keepalived/down ];then
weight -2
fi

VRRP script(s)

Adds a script to be executed periodically. Its exit code will be

    # recorded for all VRRP instances which are monitoring it.
    vrrp_script <SCRIPT_NAME> {
       script <STRING>|<QUOTED-STRING> # path of the script to execute
       interval <INTEGER>  # seconds between script invocations, default 1 second
       timeout <INTEGER>   # seconds after which script is considered to have failed
       weight <INTEGER:-254..254>  # adjust priority by this weight, default 0
       rise <INTEGER>              # required number of successes for OK transition
       fall <INTEGER>              # required number of successes for KO transition
       user USERNAME [GROUPNAME]   # user/group names to run script under
                                   #   group default to group of user
       init_fail                   # assume script initially is in failed state
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章