(转)apache2.2.x+tomcat7.0.x集群+…
apache http server下载地址
http://httpd.apache.org/download.cgi#apache22
这里下载的是httpd-2.2.21-win32-x86-openssl-0.9.8r.msi
tomcat下载地址
http://tomcat.apache.org/download-70.cgi
这里下载的是http://apache.etoak.com/tomcat/tomcat-7/v7.0.23/bin/apache-tomcat-7.0.23.zip
jk下载地址
http://labs.renren.com/apache-mirror//tomcat/tomcat-connectors/jk/binaries/windows/
这里下载的是tomcat-connectors-1.2.32-windows-i386-httpd-2.2.x.zip
首先安装apache
然后解压缩tomcat,并将tomcat复制出两份
解压缩jk
将mod_jk.so文件复制到apache/modules文件夹
修改apache/conf/httpd.conf文件
在当前文件最后写入
include conf/mod_jk.conf
在apache/conf目录中,建立mod_jk.conf文件,文件内容如下
#加载mod_jk Module
LoadModule jk_module modules/mod_jk.so
#指定 workers.properties文件路径
JkWorkersFile conf/workers.properties
#指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器
JkMount /**.do controller
JkMount /**.html controller
JkMount /* controller
在apache/conf目录中,建立workers.properties文件,内容如下
worker.list =
controller,tomcat1,tomcat2
#========tomcat1========
worker.tomcat1.port=18009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 1
#========tomcat2========
worker.tomcat2.port=28009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1
#========controller,负载均衡控制器========
worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2
worker.controller.sticky_session=1
修改第一个tomcat/conf/server.xml
将
<Server port="8005" shutdown
改为
<Server port="18005"
将
<Connector port="8080" protocol="HTTP/1.1"
改为
<Connector port="18080"
将
<Connector port="8009" protocol="AJP/1.3"
改为
<Connector port="18009"
将
<Engine name="Catalina" defaultHost="localhost"
增加jvmRoute
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"
在<Engine name="Catalina"这个标签的下面添加