您的位置:首页 > 其它

keepalived 几种健康监测方式

2015-12-07 09:27 525 查看
一./etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
test@abc.com
}
notification_email_from test@abc.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id wfc
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass pass_wfc
}
virtual_ipaddress {
10.21.10.32
}
}
virtual_server 10.21.10.32 6667 {
delay_loop 6
lb_algo wlc
lb_kind DR
ops
persistence_timeout 50
protocol TCP
nat_mask 255.255.255.0
include realserver_wfc
}

二./etc/keepalived/realserver_wfc

1.80 port
real_server 10.21.10.30 80 {
weight 1
HTTP_GET {
url {
path /keeptest/index.html
digest 3b9bc8d36a113971683321ad4fa02daf
}
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
}

}
/usr/bin/genhash -s 10.21.10.30 -p 80 -u /keeptest/index.html

2.自带检测
/etc/keepalived/realserver_wfc

real_server 10.21.10.30 80 {
weight 4
include only_tcp_80

}
/etc/keepalived/only_tcp_80

TCP_CHECK {
connect_timeout 5
connect_port 80
}

3.脚本检测
/etc/keepalived/realserver_wfc

real_server 10.21.10.30 80 {
weight 1
MISC_CHECK {
misc_path "/etc/keepalived/check_port.sh 10.21.10.30 80"
misc_timeout 10
}

}
4.脚本如下
/etc/keepalived/check_port.sh

#!/bin/bash
/usr/bin/nc -z -w1 $1 $2 | grep succeeded > /dev/null
exit $?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  keepalived