切換到幻燈片模式
需要配置前端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>
以上配置將來自80的請求分發(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.啟動應(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
以上啟動了兩個應(yīng)用服務(wù)器a和b.
4.啟動前端WEB服務(wù)器:
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,說明負(fù)載均衡Servlet工作正常。
關(guān)掉一個應(yīng)用服務(wù)器,再次訪問,會發(fā)現(xiàn)訪問正常。