Windows下的集群参考:http://cuisuqiang.iteye.com/blog/2070357
Linux上安装Apache与问题说明:http://cuisuqiang.iteye.com/blog/2070460
因为已经有了使用ajp_proxy的示例,Apache自己集成,而且就是改参数的事情,所以这里集群时使用JK来做
下载jk:http://tomcat.apache.org/download-connectors.cgi
下载文件:tomcat-connectors-1.2.40-src.tar.gz
解压安装等操作:
tar -zxvf tomcat-connectors-1.2.40-src.tar.gz cd tomcat-connectors-1.2.40-src cd native ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=/usr/jdk1.6 make make install cp apache-2.0/mod_jk.so /usr/local/apache2/modules/
/usr/local/apache2/conf/httpd.conf
增加
include /usr/local/apache2/conf/mod-jk.conf
新建mod-jk.conf配置文件
#加载mod_jk模块,注意名称与modules目录下的文件名保持一致. LoadModule jk_module /usr/local/apache2/modules/mod_jk.so #指定workers.properties文件目录. JkWorkersFile /usr/local/apache2/conf/workers.properties #指定哪些请求由tomcat处理,controller为workers.properties文件里指定的负载控制器. JkMount /* controller #JkMount /*.html controller #JkMount /*.jsp controller #JkMount /*.do controller #JkMount /servlet/* controller #JkUnMount /index.html controller
新建workers.properties配置文件
worker.list = controller #不指定报错Could not find a worker for worker name=controller #========tomcat1======== worker.tomcat1.port=8019 worker.tomcat1.host=localhost worker.tomcat1.type=ajp13 worker.tomcat1.lbfactor=1 #========tomcat2======== worker.tomcat2.port=8029 worker.tomcat2.host=localhost worker.tomcat2.type=ajp13 worker.tomcat2.lbfactor=1 #========tomcat3======== worker.tomcat3.port=8039 worker.tomcat3.host=localhost worker.tomcat3.type=ajp13 worker.tomcat3.lbfactor=3 #========tomcat4======== worker.tomcat4.port=8049 #指定tomcat2服务器AJP的端口,默认为8009 worker.tomcat4.host=localhost #指定tomcat2服务器IP或域名 worker.tomcat4.type=ajp13 #指定tomcat2与apache AJP通讯协议 worker.tomcat4.lbfactor=3 #指定负载平衡因数,只有启用了负载平衡才有用. #========controller负载平衡控制器======== worker.controller.type=lb #指定controller类型 worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3,tomcat4 #指定负载平衡的tomcat worker.controller.sticky_session=true #指定是否粘性session worker.controller.sticky_session_force=false worker.connection_pool_size=3000 worker.connection_pool_minsize=50 worker.connection_pool_timeout=50000 # session配置说明: #当sticky_session,sticky_session_force都为true时不复制session, #sticky_session_force=false指集群中某台服务器多次请求没有响应,则转发到其它服务器处理, #sticky_session=false不使用粘性session,同时配置不复制session时,注意转发请求后可能会找不到原来的session.
看到了我这里配置了四个集群,因为在Windows上已经使用,所以这里我直接指定他的AJP端口即可
启动Apache访问应用即可
请您到ITEYE网站看 java小强 原创,谢谢!
http://cuisuqiang.iteye.com/!