Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1437527
  • 博文数量: 463
  • 博客积分: 10540
  • 博客等级: 上将
  • 技术积分: 5450
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-12 08:30
文章分类

全部博文(463)

文章存档

2014年(2)

2012年(14)

2011年(42)

2010年(18)

2009年(78)

2008年(35)

2007年(182)

2006年(92)

我的朋友

分类: LINUX

2007-09-22 15:42:38

使用apache2.0.57+tomcat5.5.9+mod_jk_1.2.15配置tomcat集群

mod_jk_1.2.15下载点
1。apache2.0.57安装
    $ gzip -d httpd-2.0.42.tar.gz
    $ tar xvf httpd-2.0.42.tar
    $ ./configure --enable-mods-shared=most --enable-ssl=shared
    $ make
    $ make install
2。tomcat5.5.9安装
    # unzip jakarta-tomcat-5.5.9.zip
    # chmod a+x jakarta-tomcat-5.5.9/bin/*.sh
3. mod_jk安装
  # cd /usr/local/
  # tar xzvf jakarta-tomcat-connectors-1.2.14-src.tar.gz
  # cd jakarta-tomcat-connectors-1.2.14-src/jk/native
  # chmod 755 buildconf.sh
  # ./buildconf.sh
  # ./configure --with-apxs=/usr/local/apache/bin/apxs
  # make
  # make install
  # cd /usr/local/jakarta-tomcat-connectors-jk1.2.14-src/jk/native/apache-2.0/
  # cp mod_jk.so /usr/local/apache/modules/
4. apache2 配置
修改httpd.conf
在# LoadModule foo_module modules/mod_foo.so"下面加入
#
# Load mod_jk
#
LoadModule jk_module modules/mod_jk.so

在末尾加入
#
# Configure mod_jk
#
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /*.jsp loadbalancer
JkMount /servlet/* loadbalancer

创建workers.properties文件
#
# workers.properties
#
# In Unix, we use forward slashes:
ps=/
# list the workers by name
worker.list=tomcat1, tomcat2, loadbalancer
# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat1.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=100

# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=8109
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat2.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat2.lbfactor=100

# ------------------------
# Load Balancer worker
# ------------------------
#
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
#  ----> If a worker dies, the load balancer will check its state
#        once in a while. Until then all work is redirected to peer
#        worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2
#
# END workers.properties
#
这里tomcat1和tomcat2的端口分别是8009,8109
5. tomcat设置
修改server.xml文件
5.1。Add a unique jvmRoute to the Catalina engine
修改

并启用(原来被注释掉的)

但是要把下面的

注释掉
tomcat2的server.xml上把jvmRoute="tomcat1"改成jvmRoute="tomcat2"
5.2。Change the control port
修改

tomcat2的server.xml上把8005改成8105,tomcat1不变
5.3. Change the AJP13 port
修改
    port="8009"

    port="8109"
tomcat2的server.xml上把8009改成8109,tomcat1不变
5.4. Disable the standalone HTTP port
We don't want or need our tomcat servers to directly respond to HTTP requests. So we comment out the HttpConnector section between lines and 58 in the server.xml file.
Example:

   
NOTE: If you don't comment this out, you will need to change the port numbers so they don't conflict between tomcat instances.
5.5.Disable the WARP connector
At line 314, comment out the tag.
Example:

Do not forget to do the same thing to tomcat2's server.xml file.
NOTE: You might want to comment out the entire element. If so, make sure and remove the comments within it - XML doesn't like comments within comments.
5.6.
把一下这行改成,增加了protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler",
有些文档上没说
    
  protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
  
  redirectPort="8443" protocol="AJP/1.3" />
6.测试
创建测试页面



<%= request.getSession().getId() %>

Tomcat 2



 
阅读(1673) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~