Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2248812
  • 博文数量: 310
  • 博客积分: 6853
  • 博客等级: 准将
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-04 16:41
文章分类

全部博文(310)

文章存档

2013年(17)

2012年(42)

2011年(76)

2010年(71)

2009年(99)

2007年(2)

2006年(1)

2005年(2)

分类: 系统运维

2009-04-22 21:06:01

jk的版本要与apache的版本相匹配。一般jk开发的进度比较慢,所以需要按照jk支持的版本来下载http server。

为了确保配置顺利,可以逐步配置逐渐测试。这样好定位问题的位置。

快速配置:

1、安装apache,并测试
2、添加mod_jk
2a、在http.conf文件的末尾增加:

# Load mod_jk module
    LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so
    # Declare the module for <IfModule directive> (remove this line on Apache 2.0.x)
    #AddModule mod_jk.c
    # Where to find workers.properties
    JkWorkersFile conf/workers.properties
    # Where to put jk shared memory
    #JkShmFile /var/log/httpd/mod_jk.shm
    # Where to put jk logs
    JkLogFile logs/mod_jk.log
    # Set the jk log level [debug/error/info]
    JkLogLevel info
    # Select the timestamp log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    # Send servlet for context /examples to worker named worker1
    #JkMount /examples/servlet/* worker1
    # Send JSPs for context /examples to worker named worker1
    #JkMount /examples/*.jsp worker1
JkMount /jkstatus mystatus


2b、增加:workers.properties文件,内容如下:

worker.list=mystatus
worker.mystatus.type=status


2c、添加 mod_jk-1.2.30-httpd-2.2.3.so 文件到相应目录
2d、测试jk模块是否可用,访问 localhost/jkstatus
2e、查看jk log,正常时如下:
[Fri Oct 22 22:39:34 2010] [440:2320] [info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[Fri Oct 22 22:39:34 2010] [440:2320] [info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[Fri Oct 22 22:39:35 2010] [2676:2700] [info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[Fri Oct 22 22:39:35 2010] [2676:2700] [info] mod_jk.c (3189): mod_jk/1.2.30 initialized


3、jk配置正确好,修改workers.properties文件,增加相应tomcat信息。


下面为注意点:

jk uri映射方式有三种:
--------------------
1、JkMount /jkstatus mystatus
2、worker.jk-manage.mount=/admin/status/jk
3、独立文件配置:uriworkermap.properties 
/private/admin/mystatus=mystatus


 JkAutoAlias可以映射tomcat应用到apache?
  # enter the full path to the tomcat webapps directory
  JkAutoAlias /opt/tomtact/webapps

  # Mount 'servlets-examples' directory. It's physical location
  # is assumed to be in the /opt/tomtact/webapps/servlets-examples
  # ajp13w is a worker defined in the workers.properties
  JkMount /servlets-examples/* ajp13w

  # Unmount desired static content from servlets-examples webapp.
  # This content will be served by the httpd directly.
  JkUnMount /servlets-examples/*.gif ajp13w
  JkUnMount /servlets-examples/*.jpg ajp13w

打开AJP
----------
#vi /usr/local/tomcat/conf/server.xml
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"   
redirectPort="8443" protocol="AJP/1.3" />   第101行

session粘滞需要配置jvmRoute
----------------------------
If you want to use session stickiness, you must set different jvmRoute attributes in the Engine element in Tomcat's server.xml. Furthermore the names of the workers which are managed by the balancer have to be equal to the jvmRoute of the Tomcat instance they connect with. 

若第二台tomcat,将jvmRoute的修改为tomcat2


连接数量的确定
jk
connection_pool_timeout connection_pool_timeout to 600 (seconds)

connection_pool_size
与apache集成时,apache意见不用设置,那connection_pool_minsize是否也不用设置
The maximum connection pool size can be configured with the attribute connection_pool_size. We generally do not recommend to use this attribute in combination with Apache httpd. For Apache httpd we automatically detect the number of threads per process and set the maximum pool size to this value. For IIS we use a default value of 250 (before version 1.2.20: 10), for the Sun Web Server the default is "1". We strongly recommend adjusting this value for IIS and the Sun Web Server to the number of requests one web server process should be able to send to a backend in parallel. You should measure how many connections you need during peak hours without performance problems, and then add some percentage depending on your growth rate etc. Finally you should check, whether your web server processes are able to use at least as many threads, as you configured as the pool size.

The JK attribute connection_pool_minsize defines, how many idle connections remain when the pool gets shrunken. By default this is half of the maximum pool size.


AJP参数
-------------
maxThreads
minSpareThreads
maxSpareThreads
connectionTimeout (The number of milliseconds this Connector will wait,)

安全方面的设置:
---------------
Warning: If Apache httpd and Tomcat are configured to serve content from the same filing system location then care must be taken to ensure that httpd is not able to serve inappropriate content such as the contents of the WEB-INF directory or JSP source code. 

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