Linux(64位)下 apache-2.2.22与tomcat6.0.37 横向集群

Jdk的安装参见:

http://blog.csdn.net/supercrsky/article/details/8283200

apache的安装参见:

http://blog.csdn.net/supercrsky/article/details/8308055

文中用到的mod_jk.so 版本为1.2.30通用版,这个版本适用基于http-2.2.22的win/Linux,32/64位的环境。

下载地址:http://download.csdn.net/detail/supercrsky/5886045

httpd-2.2.22   tomcat6.0.37

全部配置文件

1.在/usr/local/apache2.2/conf下新建workers.properties文件:

内容如下:

worker.list = controller
#tomcat1
worker.tomcat1.port=8009       
worker.tomcat1.host=192.168.1.113
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
#tomcat2
worker.tomcat2.port=8009     
worker.tomcat2.host=192.168.1.114
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
#========controller========
worker.controller.type=lb
worker.controller.balance_workers=tomcat1,tomcat2
worker.lbcontroller.sticky_session=false
worker.controller.sticky_session_force=1
worker.connection_pool_size=3000
worker.connection_pool_minsize=50
worker.connection_pool_timeout=50000

2.在/usr/local/apache2.2/conf下新建mod_jk.conf文件:

内容如下:

LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.X.so
JKWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
<VirtualHost *>
DocumentRoot /usr/local/www/edu
<Directory "/usr/local/www/edu">
    AllowOverride None
    Order allow,deny
          Allow from all
</Directory>
<Directory "/usr/local/www/edu/WEB-INF">
         Order deny,allow
         Deny from all
</Directory>
ServerAdmin localhost
ServerName localhost
DirectoryIndex index.html index.htm index.jsp index.do index
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
JkMount /* controller
JkUnMount /*.gif controller
JkUnMount /*.jpeg controller
JkUnMount /*.bmp controller
JkUnMount /*.jpg controller
JkUnMount /*.png controller
JkUnMount /*.htm controller
JkUnMount /*.html controller
JkUnMount /*.js controller
JkUnMount /*.css controller
</VirtualHost>

其中

DocumentRoot /usr/local/www/edu
<Directory "/usr/local/www/edu">
    AllowOverride None
    Order allow,deny
          Allow from all
</Directory>
<Directory "/usr/local/www/edu/WEB-INF">
         Order deny,allow
         Deny from all
</Directory>
要根据实际情况来配置,如果此段不配置,会无法显示那些不转发的静态内容。

我这里是直接用ip地址访问项目,不用加工程名,所以直接配置到/usr/local/www/edu目标,edu是项目名称。

如果有多个项目可以配置多个VirtualHost节点。


其中JkMount要与JkUnMount成对出现,JkUnMount的优先级要高于JkMount。

JkMount:希望交于tomcat处理的,JkUnMount:不希望交于tomcat 处理的,一般都是静态内容。
3.在在/usr/local/apache2.2/conf/httpd.conf文件中最末尾加上

include "conf/mod_jk.conf"

4.修改tomcat/conf/server.xml文件:

找到:

<Engine name="Catalina" defaultHost="localhost" >
修改为
 <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
其中jvmRoute=tomcat1中的tomcat1要与workers.properties中的worker配置对应。

然后取消掉

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

的注释。

找到Host节点

 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

		<Context path="" docBase="/usr/local/www/edu" reloadable="true" crossContext="true" /> 

      </Host>

加入Context配置并且删除webapps下的同名项目,这样就可以通过直接访问ip来访问项目。


另一台机器的tomcat2也做同样修改。

5.依次启动tomcat1,tomcat2,apache http server 进行访问,测试成功。



你可能感兴趣的:(Linux(64位)下 apache-2.2.22与tomcat6.0.37 横向集群)