tomcat6 + apache2 集群配置

参考

1安装apache2.2

2装2台tomcat(本机ip:192.168.190.241)(另台192.168.190.200)

3配置apache文件

3.1

下载(jk,一定要与apache的版本一致,查看apache版本号命令:httpd.exe-v)

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/

把mod_jk-1.2.27-httpd-2.2.10.so放在apache\modules\下

3.2配置conf/httpd.conf文件

LoadModulejk_modulemodules/mod_jk-1.2.27-httpd-2.2.10.so#加载这个模块

JkWorkersFileconf/works.properties#加载tomcat配置文件

JkLogFilelogs/mod_jk.log#日志加载文件

JkMount/*controller#此处是指定分配给tomcat的请求例如*.do*.jsp

说明controller是在works.properties的对应配置

如果是转发所有jsp文件

JkMount/*.jspcontroller

如果是在tomcat/webapps/部署个project,例如webapps/car-manager

希望输入http://localhost/car-manager由apache转发到tomcat处理

//

JkMount/car-manager/*controller#可以这样配置路径转发

在conf文件下,建立works.properties文件,内容如下

worker.list=controller,tomcat1,tomcat2#server列表

#========tomcat1========

worker.tomcat1.port=8009#ajp13端口号,在tomcat下server.xml配置,默认8009

worker.tomcat1.host=localhost#tomcat的主机地址,如不为本机,请填写ip地址

worker.tomcat1.type=ajp13

worker.tomcat1.lbfactor=2#server的加权比重,值越高,分得的请求越多

#========tomcat2========

worker.tomcat2.port=9009#ajp13端口号,在tomcat下server.xml配置,默认8009

worker.tomcat2.host=192.168.190.200#tomcat的主机地址,如不为本机,请填写ip地址

worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor=3#server的加权比重,值越高,分得的请求越多

#负载均衡分发控制器

worker.controller.type=lb

worker.controller.balanced_workers=tomcat1,tomcat2#指定分担请求的tomcat

worker.controller.sticky_session=True

4tomcat配置ajp13端口

在本地/tomcat/conf/server.xml

<Connectorport="8009"protocol="AJP/1.3"redirectPort="8443"/>#8009要与apache/works.properties配置一致

<Enginename="Catalina"defaultHost="localhost"jvmRoute="tomcat1">#tomcat1要与apache/works.properties配置一致

<Clusterclassname="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

配置192.168.190.200/tomcat/conf/server.xml

<Connectorport="9009"protocol="AJP/1.3"redirectPort="8443"/>#9009要与apache/works.properties配置一致

<Enginename="Catalina"defaultHost="localhost"jvmRoute="tomcat2">#tomcat2要与apache/works.properties配置一致

<Clusterclassname="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

5如果需要session复制

需要另外配置

相关推荐