一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

keepalived vrrp_script的一些实例配置

时间:2013-08-19 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码

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 "/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 "/tcp/127.0.0.1/443"
 interval 1
 weight -2
}

vrrp_script chk_smtp_port {
 script "/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
 }
}

热门栏目