配置 Apache 服务器 lbmethod 以实现与 tomcat 的负载平衡时出现问题

配置 Apache 服务器 lbmethod 以实现与 tomcat 的负载平衡时出现问题

我使用 apache 服务器作为 tomcat6 服务器的前端负载均衡器。我使用 lbmethod 配置使来自一个客户端的所有请求始终发送到同一个 tomcat。

<VirtualHost *:1000>
ServerAdmin [email protected]
#DocumentRoot /www/docs/dummy-host.example.com
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common

ProxyPass /balancer-manager  !
ProxyPass / balancer://mycluster/ lbmethod=byrequests nofailover=On
ProxyPassReverse / balancer://mycluster/

<Proxy balancer://mycluster>;
BalancerMember ajp://localhost:8101/ route=NodeA1000 retry=10
BalancerMember ajp://localhost:8102/ route=NodeB1000 retry=10
BalancerMember ajp://localhost:8103/ route=NodeC1000 retry=10
BalancerMember ajp://localhost:8104/ route=NodeD1000 retry=10
BalancerMember ajp://localhost:8105/ route=NodeE1000 retry=10
</Proxy>

我在后端有 5 个 tomcat。但不是来自同一客户端的所有请求都发送到同一个 tomcat,而是请求是负载平衡的。我这里遗漏了什么吗?

答案1

我同意这属于 serverfault.com,但这可能会有所帮助。

您得到的确实是标准行为。但是,您可能在会话方面遇到了困难。请在此处阅读有关会话聚类的信息:http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html

这确保会话在您的 tomcat 实例之间共享。

确保在您要部署的应用程序中将其添加distributable="true"context.xml文件中,如下所示:

<Context path="/" debug="5" reloadable="true" crossContext="true" distributable="true">

相关内容