我已经设置了Apache-Tomcat集群(Ubuntu服务器),并且我使用了tomcat支持的集群技术和mod_jk,下面的链接清晰易懂。
我在我的局域网中做了这样的事情, three computers 1 as LB and other two as tomcat web servers ,一旦我对设置完全满意,我就想到实现这个function。
我跟着很多链接,我粘贴的链接是其中之一,我configuration在不同的物理机器上。 configuration是successful ,我觉得它很容易设置。 我检查了停止一个tomcat的networking服务器,它立即开始发送请求到另一个networking服务器。 据我所知,我很清楚,这种configuration支持HA和LB.
以下是我的Apache Tomcat集群详细信息:
1 Load Balancer(192.168.1.100) 2 web Servers(192.168.1.101, 192.168.1.102) On all the three servers, I installed apache2 & tomcat6 and configured tomcat to run on port 80 with mod_jk on all the servers. Load Balancer: Configured apache2 and tomcat with mod_jk setup(both are running on port 80) As per the link I setup workers.properties with same default ports(as I'm using different machines) Web Servers: Let Actual site: www.mydomain.com which is pointing to LB Configured apache2 and tomcat with mod_jk setup(both are running on port 80) I can access web application by pointing the browser to following: http://192.168.1.101/myapp http://192.168.1.102/myapp In either of the web servers I configured tomcat virtual hosting with actual site name(www.mydomain.com) as Host Name
我有一个与tomcat jsp应用程序有关的问题。 在任何Web服务器上,如果从webapps中删除myapp目录,则负载平衡器仍然会redirect到该Web服务器,并且用户必须面向404错误页面,而apache和tomcat都不能识别并redirect到其他可用的Web服务器。
任何人有任何技术,以便在Web服务器中请求的应用程序(myapps)在Web服务器上不可用时,客户端请求被redirect到集群中的其他Web服务器?
谢谢!
更新 :1
在load balancer的workers.properties中尝试下面的worker指令。 现在,当webapps中的myapp被删除,但是显示503错误(当tomcat停止时通常会显示), 404错误页面不会显示。 但myapps被删除后,仍然无法redirect到其他可用的服务器。
worker.<worker-name-here>.fail_on_status=-404,-500,503
我强烈build议使用专为负载平衡目的而devise的工具,如haproxy。 您可以定义后端检查,从而避免以非常灵活的方式将请求发送到不可用的应用程序。
您的解决scheme也不是HA,因为负载平衡器是SPOF(单点故障)。 您可能需要添加另一台计算机并使用keepalived进行故障转移。
HAproxy可以运行在你想要的任何端口上,甚至可以平衡不同types的stream量,不仅是http,同时configuration前端(服务平衡入口点)和后端(服务实例和平衡行为的容器)。 你可以在这里看到一个例子: http : //www.tomcatexpert.com/blog/2010/07/12/trick-my-proxy-front-tomcat-haproxy-instead-apache
对于故障转移部分,我会使用keepalived。 它会检查您的活动负载平衡器是否可用,如果没有,则将其切换到辅助计算机,并将您的虚拟IP地址浮动。
你可以查看这个链接的例子: http : //www.howtoforge.com/setting-up-a-high-availability-load-balancer-with-haproxy-keepalived-on-debian-lenny