日期:2014-05-17  浏览次数:20695 次

apache和tomcat 负载及转发

1. apache server 一个?httpd-2.2.19-win32-x86


2. tomcat7 server 五个

? ?端口分别为 8081, 8082, 8083, 8084, 8085


? 对应的项目分别为 /test12, /test12, /test34, /test34,/test5


3. httpd.conf

? ??

? ? 启用:

? ? ? ?mod_proxy.so,mod_proxy_balancer.so,mod_proxy_http.so?


? ? 添加

ProxyPass /images !

ProxyPass /css !?

ProxyPass /js !

#ProxyPassReverse /examples http://127.0.0.1:8081/examples/

ProxyPass /test12 balancer://proxy12/

<Proxy balancer://proxy12>

? ? ? ? BalancerMember http://127.0.0.1:8081/test12/

? ? ? ? BalancerMember http://127.0.0.1:8082/test12/

</Proxy>

ProxyPass /test34 balancer://proxy34/

<Proxy balancer://proxy34>

? ? ? ? BalancerMember http://127.0.0.1:8083/test34/

? ? ? ? BalancerMember http://127.0.0.1:8084/test34/

</Proxy>

ProxyPass /test5 http://127.0.0.1:8085/test5/


分别8081, 8082负载test12项目,8083, 8084负载test34, 转发8085

? ?

4. 效果

? ??http://127.0.0.1/test12/test.jsp?均衡转发到 8081,8082上

? ??http://127.0.0.1/test34/test.jsp?均衡转发到 8083, 8084上

? ??http://127.0.0.1/test5/test.jsp?转发到8085上

?

5. 负载分配算法

? ? ? ? ?1) 负载分配算法?
? ? ?ProxyRequests Off????
? ? ?&l