我的运行环境: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的 和把下面的注释去掉
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、在“虚拟主机配置代码段”中添加:(此段配置可以根据你的实际情况进行修改) ServerAdmin linvsfen◎163.com DocumentRoot "d:/ Tomcat51/webapps/jsp-examples ServerName localhost ErrorLog logs/error_log CustomLog logs/access_log common
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不变 (责任编辑:包春林)
|