in 未分类

高可用haproxy+keepalived(三)

实现后端web检测,需要修改haproxy.cfg文件,加上检测

backend honidmaster
        server ms01 192.168.1.92:80  maxconn 700
        server ms02 192.168.1.93:80  maxconn 700
改成
backend honidmaster
        server ms01 10.0.97.92:80  check port 80 maxconn 700
        server ms02 10.0.97.93:80  check port 80 maxconn 700

通过监听端口进行健康检测 。这种检测方式,haproxy只会去检查后端server的端口,并不能保证服务的真正可用。(不推荐)
具体可以参考 http://www.jianshu.com/p/eb4d07ff1189

也可以检测状态码

        http-check expect status 200
        server web01 10.0.97.92:80 check maxconn 700
        server web02 10.0.97.93:80 check maxconn 700

或者更多

# only accept status 200 as valid
http-check expect status 200

# consider SQL errors as errors
http-check expect ! string SQL\ Error

# consider status 5xx only as errors
http-check expect ! rstatus ^5

# check that we have a correct hexadecimal tag before /html
http-check expect rstring <!--tag:[0-9a-f]*</html>

https://cbonte.github.io/haproxy-dconv/configuration-1.4.html#1.3

Write a Comment

Comment