vrrp_script chk_sshd { script "killall -0 sshd" # cheaper than pidof interval 2 # check every 2 seconds weight -4 # default prio: -4 if KO } vrrp_script chk_haproxy { script "killall -0 haproxy" # cheaper than pidof interval 2 # check every 2 seconds } vrrp_script chk_http_port { script "</dev/tcp/127.0.0.1/80" # connects and exits interval 1 # check every second weight -2 # default prio: -2 if connect fails } vrrp_script chk_https_port { script "</dev/tcp/127.0.0.1/443" interval 1 weight -2 } vrrp_script chk_smtp_port { script "</dev/tcp/127.0.0.1/25" interval 1 weight -2 } vrrp_instance VI_1 { interface eth0 state MASTER virtual_router_id 51 priority 100 virtual_ipaddress { 192.168.200.18/25 } track_interface { eth1 weight 2 # prio = +2 if UP eth2 weight -2 # prio = -2 if DOWN eth3 # no weight, fault if down } track_script { chk_sshd # use default weight from the script chk_haproxy weight 2 # +2 if process is present chk_http_port chk_https_port chk_smtp_port } } vrrp_instance VI_2 { interface eth1 state MASTER virtual_router_id 52 priority 100 virtual_ipaddress { 192.168.201.18/26 } track_interface { eth0 weight 2 # prio = +2 if UP eth2 weight -2 # prio = -2 if DOWN eth3 # no weight, fault if down } track_script { chk_haproxy weight 2 chk_http_port chk_https_port chk_smtp_port } }
本文转自 yntmdr 51CTO博客,原文链接:http://blog.51cto.com/yntmdr/1618521,如需转载请自行联系原作者