隨筆 - 1, 文章 - 44, 評論 - 2, 引用 - 0
          數據加載中……

          Apache和tomcat的集群配置

          我的運行環境:Windows2003?Server?SP4?+?J2SDK1.5.0?+?Apache2.0.54?+?Tomcat5.5.9

          ??**準備軟件:
          ??1、Apache?2.0.54???
          ??2、Tomcat?5.5.14?
          ??3、Jk2連接器(mod_jk2.so)
          一:軟件的部署和配置計劃:(修改server.xml)
          Configuration?Parameter????Instance?1????Instance?2????Instance?3
          Instance?Type??????????????Load?Balancer????Cluster?Node?1????Cluster?Node?2
          Node?name??????????????????????AP-LB?????????????TC01??????????????TC02
          Node?IP???????????????????????192.168.0.12????192.168.0.12????192.168.0.12
          Home?Directory?????????????D:/apache2????D:/tomcat51????D:/tomcat52
          Server?Ports??????????????????????????8005??????????????9005
          AJP?Connector?Ports?????????????????8009??????????????8011
          Coyote/JK2?AJP?Connector?????????????????8080??????????????9080
          Cluster?mcastAddr??????????????????????????228.0.0.4??????????????228.0.0.4
          Cluster?mcastPort??????????????????????????45564??????????????45564
          tcpListenAddress??????????????????????????192.168.0.12????192.168.0.12
          Cluster?tcpListenPort?????????????????4000?????????????4001
          Route???????????????????????????????????Tomcat51?????????????Tomcat52
          軟件的安裝步驟如下:
          1、????首先按照JDK1.5.0
          2、????安裝Apache?,按照完成后啟動Apache,使用IE訪問http://localhost?測試Apache運行是否正常。
          3、????在192.168.0.12上安裝tomcat,安裝完成后,啟動tomcat,使用IE訪問http://localhost:8080?,測試tomcat運行是否正常。
          4、????編寫一個jsp文件(sessiontest.jsp)把testsession.jsp放到webapps/jsp-examplse;,將tomcat51拷貝到的d:/下,修改名字tomcat52;
          在tomcat51中的testsession.jsp有提示信息Index?Page?Served?By?tocmat51,在tomcat52的testsession.jsp有提示信息Index?Page?Served?By?tomcat52

          4、在tc01和tc02bin下編輯startup.bat,分別添加
          set?CATALINA_HOME=D:\tomcat51和set?CATALINA_HOME=D:\tomcat52

          5、????注釋掉tc01和tc02中server.xml的
          ???<!--?Define?the?top?level?container?in?our?container?hierarchy
          <Engine?name=”Catalina”?defaultHost=”localhost”?debug=”0”>
          -->
          和把下面的注釋去掉
          <Engine?name="Standalone"?defaultHost="localhost"?jvmRoute="tomcat51">
          TC02的jvmRoute="tomcat52"
          6、????在TC01的jk2.properties添加:
          #?Sample?jk2.properties?file?for?Tomcat5A
          channelSocket.address=192.168.0.12
          channelSocket.port=8009
          shm.file=D:/Apache2/conf/jk2.shm

          TC02的channelSocket.port=8011

          7、將mod_jk2.so復制到d:\Apache2\modules目錄下:
          ??1.編輯d:\Apache2\conf\httpd.conf文件,在LoadModule那一段代碼中添加:
          ??LoadModule?jk2_module?modules/mod_jk2.so
          8、將AddDefaultCharset?ISO-8859-1?改為?AddDefaultCharset?GB2312?使Apache自動支持中文顯示;
          9、在“虛擬主機配置代碼段”中添加:(此段配置可以根據你的實際情況進行修改)
          ??<VirtualHost?*:80>
          ????ServerAdmin?linvsfen◎163.com
          ????DocumentRoot?"d:/?Tomcat51/webapps/jsp-examples
          ????ServerName?localhost
          ????ErrorLog?logs/error_log
          ????CustomLog?logs/access_log?common
          ??</VirtualHost>

          10、建立并配置Apache2/conf/?workers2.properties,如下:
          ??????#?Usually?commented?out?on?production?environments
          [logger.apache2]
          file=”D:/Apache2/logs/error.log”
          level=ERROR
          #?Provide?the?basic?config?needed
          [config]
          file=D:/Apache2/conf/workers2.properties
          debug=1
          #?Provide?the?location?of?shm?file?on?the?Apache?web?server
          [shm]
          file=D:/Apache2/conf/jk2.shm
          size=1000000

          #?Tomcat51
          [channel.socket:192.168.0.12:8009]
          host=192.168.0.12
          port=8009
          tomcatId=tomcat51
          group=balanced
          lb_factor=1
          route=tomcat51
          #?Tomcat5A?worker
          [ajp13:192.168.0.12:8009]
          channel=channel.socket:tomcat51

          #?Tomcat52
          [channel.socket:192.168.0.12:8011]
          host=192.168.0.12
          port=8011
          tomcatId=tomcat52
          group=balanced
          lb_factor=1
          route=tomcat52
          #?Tomcat52?worker
          [ajp13:192.168.0.12:8011]
          channel=channel.socket:tomcat52

          #?Load?balanced?worker
          [lb:balanced]
          worker=ajp13:192.168.0.12:8009
          worker=ajp13:192.168.0.12:8011
          timeout=30
          attempts=2
          recovery=90
          stickySession=1

          noWorkersMsg=Server?Busy?please?retry?after?some?time.
          noWorkerCodeMsg=503
          #?URI?mapping
          [uri:/jsp-examples/*]
          info=Mappings?for?the?Tomcat?context?jsp-examples
          context=/jsp-examples
          group=balanced
          #?Define?a?status?worker?to?test?the?run-time?request?behavior?to?the?all?workers
          [status:]
          #?Status?URI?mapping
          [uri:/jkstatus/*]
          group=status
          11、啟動Apache和同時啟動tomcat服務。

          二.測試集群功能
          1、訪問http://localhost/jsp-examples/sessiontest.jsp,?Apache將請求發給TC01,返回結果,頁面顯示信息tomcat51。URL不變
          2、再打開一個IE窗口,訪問http://192.168.0.12/jsp-examples/sessiontest.jsp
          Apache將請求發給TC02,返回結果。頁面有信息:tomcat52,URL不變

          posted on 2006-07-11 12:00 ASONG 閱讀(270) 評論(0)  編輯  收藏 所屬分類: 應用服務器

          主站蜘蛛池模板: 临清市| 繁昌县| 腾冲县| 昂仁县| 揭东县| 金寨县| 维西| 吉木萨尔县| 东丰县| 巧家县| 鄂尔多斯市| 海兴县| 都兰县| 视频| 凉城县| 南投市| 仁怀市| 修武县| 虎林市| 崇礼县| 广汉市| 平邑县| 兴隆县| 阳春市| 开化县| 聂荣县| 伊春市| 商水县| 泽库县| 苏尼特左旗| 北川| 乾安县| 年辖:市辖区| 盐津县| 萝北县| 青岛市| 郧西县| 宜都市| 聊城市| 烟台市| 洮南市|