日期:2014-05-17  浏览次数:21062 次

apache tomcat 整合集群设置

修改apache的conf目录下的httpd.conf文件,

在最后加上一行

Include /usr/local/apache/conf/mod_jk2.conf

?

然后在/usr/local/apache/conf目录下创建 mod_jk2.conf 文件

LoadModule jk_module modules/mod_jk.so

JkWorkersFile /usr/local/apache/conf/workers2.properties

JkLogFile /usr/local/apache/logs/mod_jk.log
# Set the jk log level [debug/error/info]

JkLogLevel info
# Select the log format

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format

JkRequestLogFormat "%w %V %T"

JkMount /feedback* loadbalancer
JkMount /dac*  loadbalancer
JkMount /*     another


JkUnMount /*.jpg loadbalancer

JkUnMount /*.gif loadbalancer

JkUnMount /*.swf loadbalancer

JkUnMount /*.bmp loadbalancer
JkUnMount /*.png loadbalancer

?

这里配置了两个tomcat服务器,一个是loadbalancer,另一个是another,

然后在/usr/local/apache/conf目录下创建workers2.properties,指定两个tomcat的端口相应信息

workers.tomcat_home=/root/software/apache-tomcat-6.0.18
workers.java_home=/root/software/jdk1.6

worker.list=loadbalancer,another

# Define the first node...

worker.loadbalancer.port=8111

worker.loadbalancer.host=localhost

worker.loadbalancer.type=ajp13

# Define the 2nd node...

worker.another.port=8222

worker.another.host=localhost

worker.another.type=ajp13

?loadbalancer 的ajp转发端口是8111,host是localhost,用的是ajp13协议转发,

?aonther的ajp转发端口是8222,host是localhost,用的是ajp13协议转发,

?

然后loadbalancer这台tomcat服务器需要在server.xml修改一行,

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

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

?

这里的worker.loadbalancer.port=8111指定的端口是server.xml的

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8111" protocol="AJP/1.3"redirectPort="8443" />

这里的端口

同理another tomcat服务器也需要相应修改。

?

刚开始连不上是因为端口配错了,配成tomcat的连接端口去了。?

?

?