Resin 3.1 pro版本中集群與負(fù)載均衡的實(shí)現(xiàn)
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層和后端應(yīng)用層:
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>
以上配置將來(lái)自80的請(qǐng)求分發(fā)給app-tier應(yīng)用層集群處理。
2.應(yīng)用層集群配置:
<!-- 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òng)應(yīng)用層服務(wù)器:
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
以上啟動(dòng)了兩個(gè)應(yīng)用服務(wù)器a和b.
4.啟動(dòng)前端WEB服務(wù)器:
1 |
> D:\resin-pro-3.1.3\httpd.exe -conf conf/resin-web.conf -server web-a |
5.寫(xiě)測(cè)試JSP a.jsp:
1 |
<%System.out.println("aaaaaaaaaaaa");%> |
6.在瀏覽器中訪問(wèn):
http://localhost/a.jsp
觀察一下控制臺(tái),會(huì)在兩個(gè)窗口控制臺(tái)輪流打印出 aaaaaaaaaaaa,說(shuō)明負(fù)載均衡Servlet工作正常。
關(guān)掉一個(gè)應(yīng)用服務(wù)器,再次訪問(wèn),會(huì)發(fā)現(xiàn)訪問(wèn)正常。
posted on 2008-03-03 14:11 都市淘沙者 閱讀(3596) 評(píng)論(5) 編輯 收藏 所屬分類: Tomcat/Weblogic/Resin/Jboss