您的位置:首页 > 运维架构 > Tomcat

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

2015-07-30 17:22 691 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: