日期:2014-05-16  浏览次数:20820 次

apache2.2 tomcat6 jk 负载均衡, 做backup server

1.下载 在http://tomcat.apache.org/connectors-doc/

下载JK-1.2.30

mod_jk-1.2.30-httpd-2.2.3.so    

apache2.2,tomcat6,下载下来

2. 把

mod_jk-1.2.30-httpd-2.2.3.so    

放到apache2.2/modules下

?

3. apache2.2 配置3个文件:

?

(1)mod_jk.conf #负责配置mod-jk 模块新建一个文件,放置在apache2.2/conf/extra 文件夹下

?

内容:

#####################
# jk module
#####################

#加载jk模块
LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so


#表明workers文件,里面配置的workers用于负责响应不同请求,负载均衡等
JkWorkersFile conf/workers.properties

?

#用于配置特定uri由哪个worker来响应
JkMountFile conf/uriworkermap.properties

?

#日志文件
JkLogFile logs/mod_jk.log

?

#日志打印级别
JkLogLevel info

?

#日志格式
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

?

#请求日志
JkRequestLogFormat "%w %V %T"

?

#有种status worker,用于监控 mod-jk状态
#限制worker jk-manager 只能在本地访问
<Location /jk-manager>
??? JkMount jk-manager
??? Order deny,allow
??? Deny from all
??? Allow from 127.0.0.1
</Location>

?

?

(2)workers.properties 里面配置的workers用于负责响应不同请求,负载均衡等

此文件可在 jk 项目的源文件里获得到

?

内容:

?

写道
# Licensed to the Apache Software Foundation (ASF) under one or more
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note that the distributed version of this file requires modification
# before it is usable.
#
# Reference documentation: http://tomcat.apache.org/connectors-doc/reference/workers.html
#
# As a general note, the characters $( and ) are used internally to define
# macros. Do not use them in your own configuration!!!
#
# Whenever you see a set of lines such as:
# x=value
# y=$(x)\something
#
# the final value for y will be value\something

# 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
# error_escalation_time: seconds, default = recover_time/2 (=30)
# Determines, how fast a detected error should switch from
# local error state to global error state
# Since: 1.2.28
worker.balancer.error_escalation_time=0

# - max_reply_timeouts: number, default=0
# If there are to many reply timeouts, a worker
# is put into the error state, i.e. it will become
# unavailable for all sessions residing on the respective
# Tomcat. The number of tolerated reply timeouts is
# configured with max_reply_timeouts. The number of
# timeouts occuring is divided by 2 once a minute and the
# resulting counter is compared against max_reply_timeouts.
# If you set max_reply_