Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server » Tomcat  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Apache add Tomcat (for same or different host)
LIONEL_C





发贴: 4
积分: 0
于 2006-11-03 16:28 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Apache與Tomcat在不同機器上,Apache佔一台,兩個Tomcat亦各佔一台。

下載與Apache版本相應的mod_jk
http://apache.hkmirror.org/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.19/
將其複製到Apache目錄中modules目錄下。

Apache目錄中conf目錄下建立workers.properties,其内容如下:

worker.list=loadbalancer
worker.server01.port=8009
worker.server01.host=192.168.123.1
worker.server01.type=ajp13
worker.server01.lbfactor=1
worker.server01.local_worker=1
worker.server01.cachesize=1000
worker.server01.cache_timeout=600
worker.server01.socket_keepalive=1
worker.server01.socket_timeout=0
worker.server01.reclycle_timeout=300
worker.server01.retries=3

worker.server02.port=8009
worker.server02.host=192.168.123.2
worker.server02.type=ajp13
worker.server02.lbfactor=1
worker.server02.local_worker=1
worker.server02.cachesize=1000
worker.server02.cache_timeout=600
worker.server02.socket_keepalive=1
worker.server02.socket_timeout=0
worker.server02.reclycle_timeout=300
worker.server02.retries=3

worker.loadbalancer.type=lb
worker.loadbalancer.retries=3
worker.loadbalancer.balance_workers=server01,server02
worker.loadbalancer.sticky_session=true
#worker.loadbalancer.sticky_session_force=true

然後在同一目錄下的httpd.conf添加設定,內容如下:

#以下路徑為指mod_jk、workers.properties及寫入mod_jk.log之處
LoadModule jk_module modules/mod_jk-apache-2.2.3.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk2.log
JkLogLevel info


#設虛擬主機
<VirtualHost *:80>
ServerAdmin 127.0.0.1
DocumentRoot "C:/Program Files/Apache Software Foundation/Tomcat 5.5/conf"
ServerName localhost
DirectoryIndex index.html index.htm index.jsp
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
JkMount /* loadbalancer
</VirtualHost>



到兩個不同站台的Tomcat目錄下conf目錄中server.xml的:

<Engine name="Catalina" defaultHost="localhost" >

更改為:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="server01">

<Engine name="Catalina" defaultHost="localhost" jvmRoute="server02">

index.jsp測試頁面:

<%=session.getId()%>


大功告成!




话题树型展开
人气 标题 作者 字数 发贴时间
11572 Apache add Tomcat (for same or different host) LIONEL_C 2027 2006-11-03 16:28

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923