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

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

猜你喜欢

转载自blog.csdn.net/IamstudyingJava/article/details/47153373