隨筆-153  評(píng)論-235  文章-19  trackbacks-0
          參照:  http://www.360doc.com/showWeb/0/0/207707.aspx

          環(huán)境:
          Tomcat 5.5.20
          Apache 2.2.3


          1.機(jī)器A 里有TomcatA\webapps\Test目錄, 機(jī)器B里TomcatB\webapps\Test目錄。其web.xml文件一樣,兩個(gè)都在</web-app>之前加上<distributable/>

          2.兩個(gè)Tomcat\conf\server.xml的如下內(nèi)容去掉注釋?zhuān)瑳](méi)有就在</Host>之前加上去:


          <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
                           managerClassName
          ="org.apache.catalina.cluster.session.DeltaManager"
                           expireSessionsOnShutdown
          ="false"
                           useDirtyFlag
          ="true"
                           notifyListenersOnReplication
          ="true">

                      
          <Membership 
                          
          className="org.apache.catalina.cluster.mcast.McastService"
                          mcastAddr
          ="228.0.0.4"
                          mcastPort
          ="45564"
                          mcastFrequency
          ="500"
                          mcastDropTime
          ="3000"/>

                      
          <Receiver 
                          
          className="org.apache.catalina.cluster.tcp.ReplicationListener"
                          tcpListenAddress
          ="auto"
                          tcpListenPort
          ="4001"
                          tcpSelectorTimeout
          ="100"
                          tcpThreadCount
          ="6"/>

                      
          <Sender
                          
          className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                          replicationMode
          ="pooled"
                          ackTimeout
          ="15000"
                          waitForAck
          ="true"/>

                      
          <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
                             filter
          =".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
                             
                      
          <Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
                                tempDir
          ="/tmp/war-temp/"
                                deployDir
          ="/tmp/war-deploy/"
                                watchDir
          ="/tmp/war-listen/"
                                watchEnabled
          ="false"/>
                                
                      
          <ClusterListener className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
                  
          </Cluster>


          3.接下來(lái)配置Apache\conf\httpd.conf
          其中這三個(gè)去掉注釋?zhuān)?br>
          LoadModule proxy_module modules/mod_proxy.so
          LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
          LoadModule proxy_http_module modules/mod_proxy_http.so


          末尾加上:
          ProxyRequests Off

          ProxyPass /helloworld balancer://mycluster stickysession
          =jsessionid nofailover=On

          <Proxy balancer://mycluster>
          BalancerMember http://
          192.168.0.100:8080
          BalancerMember http://
          192.168.0.101:8080
          </Proxy>

          <Location /balancer-manager>
          SetHandler balancer-manager
          Order Deny
          ,Allow
          Deny from all
          Allow from all
          </Location>

          <Location /server-status>
          SetHandler server-status
          Order Deny
          ,Allow
          Deny from all
          Allow from all
          </Location>


          說(shuō)明:
          ProxyPass /helloworld balancer://mycluster stickysession=jsessionid nofailover=On
          <Proxy balancer://mycluster>
          BalancerMember http://192.168.0.100:8080
          BalancerMember http://192.168.0.101:8080
          </Proxy>
          ProxyPass為代理轉(zhuǎn)發(fā)的Url,即將所有訪(fǎng)問(wèn)/helloworld的請(qǐng)求轉(zhuǎn)發(fā)到群集balancer://mycluster
          BalancerMember為群集的成員,即群集服務(wù)器AB,負(fù)載均衡服務(wù)器會(huì)根據(jù)均衡規(guī)則來(lái)將請(qǐng)求轉(zhuǎn)發(fā)給BalancerMember。


          4.測(cè)試頁(yè)面,
          TomcatA\webapps\Test\index.html內(nèi)容如下:
          <html>
          <head><title>Tomcat 5.5.20 群集1</title></head>

          <body>
          <center>Tomcat 1號(hào)機(jī)
          </center>
          </body>
          </html>


          TomcatB\webapps\Test\index.html內(nèi)容如下:
          <html>
          <head><title>Tomcat 5.5.20 群集2</title></head>

          <body>
          <center>Tomcat 2號(hào)機(jī)在TomcatB機(jī)上
          </center>
          </body>
          </html>


          啟動(dòng)TomcatA和TomcatB,再啟動(dòng)Apache
          http://localhost/helloworld/Test/index.html
          后有出現(xiàn)上面兩個(gè)頁(yè)面的任一個(gè)說(shuō)明配置成功。
          不斷刷新,這個(gè)頁(yè)面不斷交替。

          :)
          posted on 2007-03-15 16:59 流浪汗 閱讀(1580) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Tomcat
          主站蜘蛛池模板: 宝山区| 高尔夫| 扬中市| 珠海市| 石屏县| 普兰店市| 茶陵县| 饶阳县| 淅川县| 宜宾市| 石河子市| 资溪县| 县级市| 寻甸| 星座| 东港市| 安图县| 镇安县| 巴楚县| 永德县| 德安县| 兴隆县| 定西市| 中牟县| 安国市| 平果县| 牙克石市| 迁安市| 黎川县| 昭通市| 浦东新区| 昆明市| 永和县| 郎溪县| 阆中市| 山阳县| 华池县| 延长县| 牟定县| 临洮县| 神木县|