How to configure Apache and Tomcat to realize the load balancing?

本文介绍如何通过配置Apache和Tomcat实现负载均衡。主要包括:在Apache的httpd.conf中添加代理设置;配置两个Tomcat服务器的server.xml文件;以及解决防火墙问题确保AJP端口畅通。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to configure Apache and Tomcat to realize the load balancing?
1. Apache: add following to the end of httpd.conf 
apache address: 10.12.22.53
ProxyRequests Off
ProxyPass / balancer://abc/ nofailover=On
<Proxy balancer://abc/>
       BalancerMember ajp://10.12.22.91:8009 loadfactor=1 route=jvm91
       BalancerMember ajp://10.12.22.100:8039 loadfactor=1 route=jvm100
</Proxy>


There are two tomcat servers, 10.12.22.91 and 10.12.22.100 and ajp ports 8009 and 8039 respective.


2. Tomcat server.xml
10.12.22.91 
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm91">


10.12.22.100
<Connector port="8039" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm100">


Notice, AJP port and jvmRoute need be matched along with the httpd.conf.


3.  http://10.12.22.53/gridserver
sometimes it cannot success for firewall, you can close the firewall, or open the ajp port at iptables.


you can see the status via "serivce iptables status"
you can add&remove the port via "vim /etc/consys/iptables"
for add ajp port 8009 via adding the line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT
and if you want to reject the port via deleting the line
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值