# Define two status worker:
# - jk-status for read-only use
# - jk-manager for read/write use
worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true
worker.list=jk-manager
worker.jk-manager.type=status
# We define a load balancer worker
# with name "balancer"
worker.list=balancer
worker.balancer.type=lb
worker.balancer.error_escalation_time=0
worker.balancer.max_reply_timeouts=10
worker.balancer.sticky_session=true
worker.balancer.sticky_session_force=true
# Now we add members to the load balancer First member is "tomcat1", most attributes are inherited from the template "worker.template".
worker.balancer.balance_workers=tomcat1
worker.tomcat1.reference=worker.template
worker.tomcat1.host=127.0.0.1
worker.tomcat1.port=8009
worker.tomcat1.activation=A
# Second member is "tomcat2", most attributes are inherited from the template "worker.template".
worker.balancer.balance_workers=tomcat2
worker.tomcat2.reference=worker.template
worker.tomcat2.host=127.0.0.1
worker.tomcat2.port=7009
worker.tomcat2.activation=A
# Finally we put the parameters
worker.template.type=ajp13
worker.template.socket_connect_timeout=5000
worker.template.socket_keepalive=true
worker.template.ping_mode=A
worker.template.ping_timeout=10000
worker.template.connection_pool_minsize=0
worker.template.connection_pool_timeout=600
worker.template.reply_timeout=300000
worker.template.recovery_options=3
# Optionally filter out all .jpeg files inside that context
# For no mapping the url has to start with exclamation (!)
!/servlets-examples/*.jpeg=lb
#
# Mount jkstatus to /jkmanager
# For production servers you will need to
# secure the access to the /jkmanager url
#
/jk-manager=jk-manager
/jk-status=jk-status
2.3.3 httpd.conf
需要在中添加httpd的配置文件中加载jk的配置文件。
# 加载jk配置文件
#Include conf/mod_jk.conf
2.3.4 mod_jk.conf
# a versioned file name.
LoadModule jk_module modules/mod_jk_2.2_32.so
<IfModule jk_module>
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkShmFile logs/mod_jk.shm
# JkOptions +RejectUnsafeURI
# JkStripSession On
JkWatchdogInterval 60
<Location /jk-status>
# Inside Location we can omit the URL in JkMount
JkMount jk-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<Location /jk-manager>
# Inside Location we can omit the URL in JkMount
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
JkMountFile conf/uriworkermap.properties
JkMount /* balancer
# JkUnMount /myapp/static/* *
# JkUnMount /myapp/images/* balancer
# SetEnvIf REQUEST_URI "\.(htm|html|css|gif|jpg|js)$" no-jk
# SetEnvIf Request_URI "/transactions/" JK_REPLY_TIMEOUT=600000
# SetEnvIf Request_URI "/reports/" JK_REPLY_TIMEOUT=0
</IfModule>