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 方式,只能看到结果。