【发布时间】:2020-01-21 19:47:03
【问题描述】:
我们有一对运行 mod_proxy_ajp 的 Apache 2.4 Web 服务器(web02、web03)与一对 Tomcat 7.0.59 服务器(app02、app03)通信。
app03 上的 Tomcat 服务器是备用服务器,除非 app02 完全离线,否则它不应获得流量。
web02 和 web03 上的 Apache 配置:
<Proxy balancer://ajp_cluster>
BalancerMember ajp://app02:8009 route=worker1 ping=3 retry=60
BalancerMember ajp://app03:8009 status=+R route=worker2 ping=3 retry=60
ProxySet stickysession=JSESSIONID|jsessionid lbmethod=byrequests
</Proxy>
在 app02 和 app03 上为 AJP 配置 Tomcat:
<Connector protocol="AJP/1.3" URIEncoding="UTF-8" port="8009" />
我们看到 Apache 开始向 app03 发送流量的问题,即使 app02 仍然可用但可能有点忙,它仍被标记为备用。
Apache SSL 错误日志:
[Thu Sep 12 14:23:28.028162 2019] [proxy_ajp:error] [pid 24234:tid 140543375898368] (70007)The timeout specified has expired: [client 207.xx.xxx.7:1077] AH00897: cping/cpong failed to 10.160.160.47:8009 (app02)
[Thu Sep 12 14:23:28.028196 2019] [proxy_ajp:error] [pid 24234:tid 140543375898368] [client 207.xx.xxx.7:1077] AH00896: failed to make connection to backend: app02
[Thu Sep 12 14:23:28.098869 2019] [proxy_ajp:error] [pid 24135:tid 140543501776640] [client 207.xx.xxx.7:57809] AH01012: ajp_handle_cping_cpong: ajp_ilink_receive failed, referer: https://site.example.com/cart
[Thu Sep 12 14:23:28.098885 2019] [proxy_ajp:error] [pid 24135:tid 140543501776640] (70007)The timeout specified has expired: [client 207.xx.xxx.7:57809] AH00897: cping/cpong failed to 10.160.160.47:8009 (app02), referer: https://site.example.com/cart
我们的 Apache 日志中有数百条此类消息。
关于使 Apache 坚持使用app02 的设置有什么建议,除非它完全离线?
【问题讨论】:
-
“完全离线”的标准是什么?
-
@DusanBajic 我们只想在 app02 Tomcat 处于错误状态并停止提供页面或出现故障时将流量转移到 app03
-
但这不是你现在所拥有的:“无法连接到后端:app02”,所以 app02 Tomcat 处于错误状态并停止提供页面,因此流量翻转到 app03 (我认为这不是理想的行为,但是您必须更准确地了解“不良状态”和“停止服务页面”的含义)
-
另外,一般来说,虽然在 apache 中微调负载平衡可能是可行的,但也许您可能想考虑切换到更现代的反向代理,如 haproxy 或 nginx?
标签: apache tomcat mod-proxy ajp mod-proxy-ajp