Tomcat群集方案文件状态:【√】草稿【】修改稿【】正式发布文档密级:中密当前版本:V1.0作者:黄伟平完成日期:2009-11-27MochaSoftwareCo.,Ltd.客户质量团结创新1版本历史日期版本号作者备注日期版本号作者备注修改内容增加内容删除内容日期版本号作者备注修改内容增加内容删除内容MochaSoftwareCo.,Ltd.客户质量团结创新2目录版本历史......................................................................................................................................................1目录..........................................................................................................................................................21架构图..................................................................................................................................................12软件资源..............................................................................................................................................13详细步骤..............................................................................................................................................13.1端口设置......................................................................................................................................................13.2APACHE配置................................................................................................................................................23.2.1修改配置文件httpd.conf.....................................................................................................................23.2.2增加配置文件workers.properties.......................................................................................................23.2.3增加配置文件urimap.properties........................................................................................................23.3TOMCAT1配置.............................................................................................................................................33.3.1修改配置文件server.xml....................................................................................................................33.4TOMCAT2配置.............................................................................................................................................33.4.1修改配置文件server.xml....................................................................................................................33.5测试..............................................................................................................................................................34其他说明..............................................................................................................................................54.6如何设置SESSION粘连?...........................................................................................................................54.7如何设置各节点的负载权重?..................................................................................................................54.8如何设置SESSION复制?...........................................................................................................................55参考文档..............................................................................................................................................8MochaSoftwareCo.,Ltd.客户质量团结创新11架构图ApacheTomcat1Tomcat2jk2jk2前端是一个Apache,通过jk2连接器分发到后端两个Tomcat,从而达到软负载的功能。2软件资源软件名称版本备注Apache2.2.6Apache官方网站Tomcat5.5.28Apache官方网站Jk21.2.28Apache官方网站Jdk1.5.0_09Sun官方网站Apache:::详细步骤3.1端口设置Apache80Tomcat18005808084438009Tomcat28006808184448010MochaSoftwareCo.,Ltd.客户质量团结创新23.2Apache配置3.2.1修改配置文件httpd.conf把jk2文件mod_jk-1.2.28-httpd-2.2.3.so复制到apache目录modules下。在httpd.conf文件里添加以下几行LoadModulejk_modulemodules/mod_jk-1.2.28-httpd-2.2.3.soJkWorkersFileconf/workers.propertiesJkMountFileconf/urimap.properties3.2.2增加配置文件workers.properties在apache目录conf创建两个文件workers.properties,内容如下worker.list=router#DefinetheLBworkerworker.router.type=lbworker.router.balance_workers=tomcat1,tomcat2worker.router.sticky_session=1#Define1realtomcatusingajp13worker.tomcat1.type=ajp13worker.tomcat1.host=localhostworker.tomcat1.port=8009worker.tomcat1.lbfactor=1#Defineanothertomcatusingajp13worker.tomcat2.type=ajp13worker.tomcat2.host=localhostworker.tomcat2.port=8010worker.tomcat2.lbfactor=13.2.3增加配置文件urimap.properties在apache目录conf创建两个文件workers.properties,内容如下/*.jsp=router/*/servlet/*=router/cluster/*=router把tomcat应用程序的访问URI匹配到jk2的工作条目router。MochaSoftwareCo.,Ltd.客户质量团结创新33.3Tomcat1配置3.3.1修改配置文件server.xmlEnginename=CatalinadefaultHost=localhostjvmRoute=tomcat1jvmRoute值要与workers.properties文件中定义的条目worker.tomcat1保持一致。3.4Tomcat2配置3.4.1修改配置文件server.xmlServerport=8006shutdown=SHUTDOWNConnectorport=8081maxHttpHeaderSize=8192maxThreads=150minSpareThreads=25maxSpareThreads=75enableLookups=falseredirectPort=8444acceptCount=100connectionTimeout=20000disableUploadTimeout=true/Connectorport=8010enableLookups=falseredirectPort=8444protocol=AJP/1.3/上面标注红色的端口值不能与Tomcat1相同,在同一个