Resin 3.1 pro版本中集群與負載均衡的實現
resin1.conf(9.3 K) | |
resin-web.conf(8.8 K) | |
resin-313-cluster-app-1.gif(6.8 K) | |
resin-313-cluster-app-2.gif(6.8 K) | |
resin-313-cluster-web-1.gif(6.3 K) | |
需要配置前端web層和后端應用層:
1.web層配置:
<!--
- Configuration for the web-tier/load-balancer
-->
<cluster id="web-tier">
<server-default>
<!-- The http port -->
<http address="*" port="80"/>
</server-default>
<server id="web-a" address="127.0.0.1" port="6700"/>
<cache path="cache" memory-size="64M"/>
<host id="">
<web-app id="/">
<rewrite-dispatch>
<load-balance regexp="" cluster="app-tier"/>
</rewrite-dispatch>
</web-app>
</host>
</cluster>
<cluster id="app-tier">
<server id="a" address="127.0.0.1" port="6800"/>
<server id="b" address="127.0.0.1" port="6801"/>
<persistent-store type="cluster">
<init path="cluster"/>
</persistent-store>
<web-app-default>
<session-config>
<use-persistent-store/>
</session-config>
</web-app-default>
<host id="">
...
</host>
</cluster>
以上配置將來自80的請求分發給app-tier應用層集群處理。
2.應用層集群配置:
<!-- define the servers in the cluster --> <server id="a" address="127.0.0.1" port="6800"/> <server id="b" address="127.0.0.1" port="6801"/>
3.啟動應用層服務器:
D:\resin-pro-3.1.3\httpd.exe -conf conf/resin1.conf -server a
D:\resin-pro-3.1.3\httpd.exe -conf conf/resin1.conf -server b
以上啟動了兩個應用服務器a和b.
4.啟動前端WEB服務器:
1 |
> D:\resin-pro-3.1.3\httpd.exe -conf conf/resin-web.conf -server web-a |
5.寫測試JSP a.jsp:
1 |
<%System.out.println("aaaaaaaaaaaa");%> |
6.在瀏覽器中訪問:
http://localhost/a.jsp
觀察一下控制臺,會在兩個窗口控制臺輪流打印出 aaaaaaaaaaaa,說明負載均衡Servlet工作正常。
關掉一個應用服務器,再次訪問,會發現訪問正常。
posted on 2008-03-03 14:11 都市淘沙者 閱讀(3596) 評論(5) 編輯 收藏 所屬分類: Tomcat/Weblogic/Resin/Jboss