[alibaba/tengine]ngx_http_upstream_check_module 模块的问题

2024-02-21 604 views
2

1、type=tcp 后端主动健康检查,通过 error 日志(debug级别),看不到检查的过程,只能看到处理结果。 2、type=http 后端主动健康检查,最后几次检查似乎没打印日志出来。 3、Tengine 2.3.1、OS:centos 7.6 配置如下:

upstream jenkins { server 192.168.10.58:80; server 192.168.10.54:3030; server 192.168.10.68:3030; keepalive 15; check interval=2000 rise=2 fall=2 timeout=1000 type=tcp; }

upstream pay { server 192.168.10.71:6083; server 192.168.10.66:6083; server 192.168.10.57:6083; keepalive 15; check interval=2000 rise=2 fall=2 timeout=1000 type=http; check_http_send "HEAD /html/health.html HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; }

Tengine 的 error 日志如下:

2019/08/08 16:13:57 [error] 15379#0: disable check peer: 192.168.10.54:3030 2019/08/08 16:14:21 [error] 15379#0: enable check peer: 192.168.10.54:3030 2019/08/08 16:14:30 [error] 15378#0: check protocol http error with peer: 192.168.10.71:6083 2019/08/08 16:14:32 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:32 [error] 15379#0: disable check peer: 192.168.10.71:6083 2019/08/08 16:14:34 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:36 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:38 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:40 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:42 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:44 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:46 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:48 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:50 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:52 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:54 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:56 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:14:58 [error] 15379#0: send() failed (111: Connection refused) 2019/08/08 16:15:03 [error] 15380#0: enable check peer: 192.168.10.71:6083

从日志可以看到,type=http 健康检查方式,有按配置每隔2秒主动检查后端服务器状态;而 type=tcp 方式,只能看到结果。

回答

9

@weiguolau 你可以尝试设置error log的级别为debug,我本地测试是可以打印如下日志的: 2019/08/09 17:57:19 [debug] 50914#0: http check begin handler index xx.

2

哦,你打印出来的日志是 http check,你配置的应该是 type=http。我的意思是 type=tcp 的情况下,不打印检查过程的日志。 上述 http 方式检查日志,我的日志级别就是 debug 级别。

9

@weiguolau 这个就是tcp模式下打印的,这块入口函数打印日志没有区分httptcp的。

7

linux安装后,配置http健康检查后启动报错,提示 unknow directive "check" in nginx.conf,配置如下: upstream checkHttp{ server 127.0.0.1:8900; check interval=3000 rise=2 fall=5 timeout=1000 type=http; }

tengine支持http2的健康检查,网上一直没有找到例子,求大神帮忙

9

是不是你安装的时候没添加这个模块?你执行 nginx -V 试试,看看有木有 --add-module=./modules/ngx_http_upstream_check_module,如果没肯定就是没装了。