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

          環境:
          Tomcat 5.5.20
          Apache 2.2.3


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

          2.兩個Tomcat\conf\server.xml的如下內容去掉注釋,沒有就在</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.接下來配置Apache\conf\httpd.conf
          其中這三個去掉注釋:
          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>


          說明:
          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為代理轉發的Url,即將所有訪問/helloworld的請求轉發到群集balancer://mycluster
          BalancerMember為群集的成員,即群集服務器AB,負載均衡服務器會根據均衡規則來將請求轉發給BalancerMember


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

          <body>
          <center>Tomcat 1號機
          </center>
          </body>
          </html>


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

          <body>
          <center>Tomcat 2號機在TomcatB機上
          </center>
          </body>
          </html>


          啟動TomcatA和TomcatB,再啟動Apache
          http://localhost/helloworld/Test/index.html
          后有出現上面兩個頁面的任一個說明配置成功。
          不斷刷新,這個頁面不斷交替。

          :)
          posted on 2007-03-15 16:59 流浪汗 閱讀(1580) 評論(0)  編輯  收藏 所屬分類: Tomcat
          主站蜘蛛池模板: 和硕县| 周口市| 准格尔旗| 凯里市| 安乡县| 南华县| 绥化市| 栾川县| 安岳县| 广平县| 廉江市| 天祝| 南投县| 潍坊市| 溧水县| 卢龙县| 太原市| 新竹县| 金堂县| 常德市| 阿荣旗| 碌曲县| 奎屯市| 乐安县| 通榆县| 防城港市| 宣城市| 潞西市| 高唐县| 宁晋县| 嘉祥县| 弥渡县| 宝应县| 江北区| 固安县| 无棣县| 忻城县| 郴州市| 兴义市| 刚察县| 宜川县|