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

          Apache和tomcat的集群配置

          我的運行環(huán)境:Windows2003?Server?SP4?+?J2SDK1.5.0?+?Apache2.0.54?+?Tomcat5.5.9

          ??**準(zhǔn)備軟件:
          ??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、????首先按照J(rèn)DK1.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復(fù)制到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、在“虛擬主機(jī)配置代碼段”中添加:(此段配置可以根據(jù)你的實際情況進(jìn)行修改)
          ??<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服務(wù)。

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

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

          主站蜘蛛池模板: 翁牛特旗| 府谷县| 海安县| 石景山区| 昌邑市| 廊坊市| 阿拉善盟| 永州市| 浏阳市| 长寿区| 龙川县| 伊春市| 肇源县| 津南区| 遂宁市| 罗定市| 甘南县| 电白县| 大连市| 民乐县| 沈丘县| 曲阳县| 福建省| 交口县| 石城县| 堆龙德庆县| 遂溪县| 泽普县| 象山县| 甘肃省| 白沙| 阜平县| 和龙市| 新建县| 杭州市| 伊金霍洛旗| 凤城市| 喀喇| 志丹县| 龙陵县| 江山市|