linux apache和tomcat连接器mod_jk

http://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html

mod_jk
下载地址:http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/
JK版本 jk-1.2.32

//下载mod_jk1.2.32
wget http://labs.renren.com/apache-mirror//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz

JK压缩包名 jakarta-tomcat-connectors-current-src.tar.gz
这里是将其放到 ~/soft
[root@webserver ~]# tar -xzf tomcat-connectors-1.2.32-src.tar.gz -C .
[root@webserver local]# cd jakarta-tomcat-connectors-1.2.32-src/jk/native
[root@webserver native]#chmod 755 buildconf.sh
[root@webserver native]# ./buildconf.sh
[root@webserver native]#./configure
–with-apxs=/usr/local/apache2/bin/apxs  # apache apxs

[root@webserver native]# make && make install
[root@webserver native]# cd apache-2.0
[root@webserver native]#ll mod_jk.so
-rwxr-xr-x 1 root root 477305 Oct  9 08:49 mod_jk.so
可以看到mod_jk.so生成   默认会自动安装到/usr/local/apache2/modules
没有的话 需手动copy到modules下

安装时出现问题:
在 ./buildconf.sh时出现
rm autom4te.cache
libtoolize –force –automake –copy
aclocal
./buildconf.sh: line 7: libtoolize: command not found
aclocal
./buildconf.sh: line 11: aclocal: command not found
autoheader
./buildconf.sh: line 13: autoheader: command not found
automake -a –foreign –copy
./buildconf.sh: line 15: automake: command not found
autoconf
./buildconf.sh: line 17: autoconf: command not found
rm autom4te.cache
说明你没有安装aclocal,libtool,autoheader,automake,autoconf..安装一下就好
安装包在你的linux安装盘里面有,名字都是libtool-*.rpm,automake-*.rpm,包名和-之间没有其他东西
rpm -ivh *.rpm
如果有这个错误
warning::******** Header V3 DSA signature:NOKEY,key,ID
原本为 rpm -ivh ****.rpm 现在改成 rpm -ivh ****.rpm –force –nodeps就可以了,nodeps的意思是忽视依赖关系。因为各个软件之间会有多多少少的联系。有了这两个设置选项就忽略了这些依赖关系
,强制安装或者卸载

 

workers.properties 文件配置 详解  workers.properties 配置 详解  mod_jk 文件配置 详解  ajp13 配置详解

 

worker.list=用逗号隔开的worker名称

ex) worker.list=service1,batch1

worker.worker name.type=<worker type> worker 类型,可选项有(ajp12(tomcat4.0以前使用),ajp13,lb(loadbalancer))

# Defines a worker named “local” that uses the ajpv12 protocol to forward requests to a Tomcat process.

worker.local.type=ajp12

# Defines a worker named “remote” that uses the ajpv13 protocol to forward requests to a Tomcat process.

worker.remote.type=ajp13

 

# Defines a worker named “loadbalancer” that loadbalances several Tomcat processes transparently.

worker.loadbalancer.type=lb

# worker “worker2″ will talk to Tomcat listening on machine www2.x.com at port 8009 using 3 lb factor

worker.worker2.host=www2.x.com

worker.worker2.port=8009

worker.worker2.lbfactor=3

# worker “worker2″ uses connections, which will stay no more than 10mn in the connection pool

worker.worker2.connection_pool_timeout=600

# worker “worker2″ ask operating system to send KEEP-ALIVE signal on the connection

worker.worker2.socket_keepalive=1

# mount can be used as an alternative to the JkMount directive

worker.worker2.mount=/contexta /contexta/* /contextb /contextb/*

lb Worker properties

balance_workers worker.service1.balance_workers可以指定worker,这里指定了worker,可以在worker.list里不指定

# The worker balance1 while use “real” workers worker1 and worker2 wo

rker.balance1.balance_workers=worker1, worker2

sticky_session 设置是否同一个session(会话)必须在同一个worker里处理,默认为false

worker.balance1.sticky_session=false

Status Worker properties

这个worker不直接与tomcat打交道。与负载均衡有关。

# Add the status worker to the worker list w

orker.list=jkstatus

# Define a ‘jkstatus’ worker using status worker.jkstatus.type=status

# Add the jkstatus mount point Jk

Mount /jkmanager/* jkstatus

# Enable the JK manager access from localhost only

<Location /jkmanager/>

JkMount jkstatus

Order deny,allow

Deny from all

Allow from 127.0.0.1

</Location>

更详细的:http://tomcat.apache.org/connectors-doc/reference/status.html

Property file macros

你还可以在property文件里定义变量,以供后面使用

# property example, like a network base address mynet=194.226.31 # Using the above macro to simplify the address definitions # for a farm of workers. worker.node1.host=$(mynet).11 worker.node2.host=$(mynet).12 worker.node3.host=$(mynet).13

Hierarchical property configuration

worker可以继承,只有被继承的变量重新设置的值被覆盖。

# worker toe defines some default settings w

orker.toe.type=ajp13

worker.toe.socket_keepalive=true

worker.toe.connect_timeout=10000

worker.toe.recovery_options=7

# workers tic and tac inherit those values

worker.tic.reference=worker.toe

worker.tac.reference=worker.toe

这样tic和tac 跟 toe 具有同样的配置属性。可以有多个取值的属性不能被合并。ex) worker.toe.mount=/ /servletworker.tic.mount=/*.jsp这时worker.tic.mount=/*.jsp 不是 三个取值的并!reference在配置负载均衡时很有用!请看下面的例子!

# We only use one load balancer

worker.list=lb

# Let’s define some defaults

worker.basic.port=8009

worker.basic.type=ajp13

worker.basic.socket_keepalive=true

worker.basic.connect_timeout=10000

worker.basic.recovery_options=7

# And we use them in two groups

worker.lb1.domain=dom1

worker.lb1.distance=0

worker.lb1.reference=worker.basic

worker.lb2.domain=dom2

worker.lb2.distance=1

worker.lb2.reference=worker.basic

# Now we configure the load balancer

worker.lb.type=lb

worker.lb.method=B

worker.lb.balanced_workers=w11,w12,w21,w22

worker.w11.host=myhost11

worker.w11.reference=worker.lb1

worker.w12.host=myhost12

worker.w12.reference=worker.lb1

worker.w21.host=myhost21

worker.w21.reference=worker.lb2

worker.w22.host=myhost22

worker.w22.reference=worker.lb2

FAQ

http://tomcat.apache.org/connectors-doc/miscellaneous/faq.html

uriworkermap.properties configuration

http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html

workers.properties configuration

http://tomcat.apache.org/connectors-doc/reference/workers.html

Configuring Apachehttp://tomcat.apache.org/connectors-doc/reference/apache.htmlConfiguring IIShttp://tomcat.apache.org/connectors-doc/reference/iis.htmlLoadBalancer HowTohttp://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.htmlReverse Proxy HowTohttp://tomcat.apache.org/connectors-doc/generic_howto/proxy.htmlApache HTTP Server HowTohttp://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>