Apache 2.2.11+Tomcat 6.0.20集群配置
这几天一直在看Apache和Tomcat的集群配置。配置了很久,终于成功!
Apache2.x和Tomcat配置可以采用反向代理的方式(mod proxy),也可以采用JK模块,最终采用了JK模块,JK模块的效率要比反向代理高,这是Apache官方网站上说的,我没有测试过。JK配置虽然复杂,但更加灵活。
首先,下载Apache2.2.11,Tomcat6.0.20解压版,以及mod_jk-1.2.28-httpd-2.2.3.so
安装Apache服务器,将mod_jk-1.2.28-httpd-2.2.3.so重命名为mod_jk.so并拷贝到Apache安装目录下的modules文件夹中。
在Apache2.2安装目录的conf文件夹下,建立以下3个文件:
mod_jk.conf、workers.properties、uriworkermap.properties
在httpd.conf最后加上:
- # JK module settings
- Include conf/mod_jk.conf
表示将mod_jk.conf配置文件包含进来,以下是mod_jk.conf文件的内容:
- # Load JK Module
- LoadModule jk_module modules/mod_jk.so
- # Configure mod_jk
- JkWorkersFile conf/workers.properties
- JkMountFile conf/uriworkermap.properties
- JkShmFile logs/mod_jk.shm
- JkLogFile logs/mod_jk.log
- JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
- JkLogLevel warn
- JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
- HostnameLookups Off
- <Location /jkmanager/>
- JkMount jkstatus
- Order deny,allow
- Deny from all
- Allow from 127.0.0.1
- </Location>
接下来配置workers.properties文件:
- # environment slash for Windows(反斜杠代表Windows系统)
- ps=\
- worker.retries=3
- # 此处定义了一个负载均衡器和状态监视器
- worker.list=loadbalancer,jkstatus
- worker.tomcatA.type=ajp13
- worker.tomcatA.host=localhost
- worker.tomcatA.port=9001
- worker.tomcatA.lbfactor=1
- worker.tomcatA.connection_pool_timeout=600
- worker.tomcatA.socket_keepalive=true
- worker.tomcatA.socket_timeout=60
- worker.tomcatB.type=ajp13
- worker.tomcatB.host=localhost
- worker.tomcatB.port=9002
- worker.tomcatB.lbfactor=1
- worker.tomcatB.connection_pool_timeout=600
- worker.tomcatB.socket_keepalive=true
- worker.tomcatB.socket_timeout=60
- worker.tomcatC.type=ajp13
- worker.tomcatC.host=localhost
- worker.tomcatC.port=9003
- worker.tomcatC.lbfactor=1
- worker.tomcatC.connection_pool_timeout=600
- worker.tomcatC.socket_keepalive=true
- worker.tomcatC.socket_timeout=60
- worker.jkstatus.type=status
- worker.loadbalancer.type=lb
- worker.loadbalancer.sticky_session=true
- worker.loadbalancer.sticky_session_force=false
- worker.loadbalancer.balance_workers=tomcatA,tomcatB,tomcatC
上述配置文件中,sticky_session=true,sticky_session_force=false。很多文章建议,前者设置为true时,后者也设置为true。
相关推荐
Kafka 2020-09-18
Wepe0 2020-10-30
杜倩 2020-10-29
windle 2020-10-29
minerd 2020-10-28
mengzuchao 2020-10-22
Junzizhiai 2020-10-10
bxqybxqy 2020-09-30
风之沙城 2020-09-24
kingszelda 2020-09-22
大唐帝国前营 2020-08-18
yixu0 2020-08-17
TangCuYu 2020-08-15
xiaoboliu00 2020-08-15
songshijiazuaa 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
newfarhui 2020-08-03
likesyour 2020-08-01