- 浏览: 254480 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (91)
- hibernate (6)
- javaScript (9)
- flex (18)
- linux (3)
- vc (2)
- vs (0)
- arcgis (4)
- java (11)
- eclipse (5)
- php (3)
- arcgissde (3)
- arcgis server (5)
- myeclipse (1)
- spring (7)
- junit (1)
- ehcache (2)
- svn (2)
- SQL (7)
- webService (1)
- http://code.svnspot.com/ (0)
- spring security3 (8)
- maven (3)
- struts (2)
- tomcat (4)
- apache (1)
- vmware (0)
- mysql (2)
- android (2)
- jms (0)
- dbvisulizer (1)
- 百度地图 (2)
- openlayers (1)
最新评论
-
jobsccnu:
非常感谢,到处找这个代码呢
flex导出图片 -
li1045460568:
...
HibernateDao.java -
li1045460568:
[flash=200,200][flash=200,200][ ...
HibernateDao.java -
zz210891470:
会报这个错啊Exception in thread " ...
cxf webService简单例子 -
jie66989:
主要就是这个类了,这是前段时间学习的时候用的一部分,那个时候只 ...
HibernateDao.java
所需软件:
Apache2.2:http://archive.apache.org/dist/httpd/binaries/win32/
tomcat-connectors-1.2.37:http://apache.etoak.com/tomcat/tomcat-connectors/jk/source/jk-1.2.28/tomcat-connectors-1.2.28-src.zip
JK2 1.2:http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-connectors/jk/binaries/
端口设置
Apache 80
Tomcat1 8005 8080 8443 8009
Tomcat2 8006 8081 8444 8010
1.解压jk2将mod_jk.so放在Apache2.2\modules目录下
2.配置apache
打开httpd.conf对应位置添加
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkMountFile conf/urimap.properties
增加配置文件workers.properties
在apache目录conf创建两个文件workers.properties,内容如下
worker.list=router #配置请求处理server 这里可以配置多个server
参考:http://wenku.baidu.com/view/5a135db91a37f111f1855b7a.html
# Define the LB worker
worker.router.type=lb
worker.router.balance_workers=tomcat1,tomcat2 #指定分担请求的server列表,用逗号分隔
#设置用于负载均衡的server的session可否共享这里如果设置为0在复制session的时候tomcat会报错,但可以进行复制,如果设置为1就没有错误
worker.router.sticky_session=1
# Define 1 real tomcat using ajp13
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8009
worker.tomcat1.lbfactor=1
# Define another tomcat using ajp13
worker.tomcat2.type=ajp13
worker.tomcat2.host=localhost
worker.tomcat2.port=8010
worker.tomcat2.lbfactor=1
增加配置文件urimap.properties
在apache目录conf创建两个文件workers.properties,内容如下
/*.jsp=router #表示所有的jsp文件都由router这个server处理
/*/servlet/*=router
/cluster/*=router
!/*.gif=router #所有以.gif结尾的请求都不由controller这个server处理
这里的"!”类似于java中的"!”,是“非”的意思
把tomcat应用程序的访问URI匹配到jk2的工作条目router。
3.Tomcat1配置
1 修改配置文件server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
jvmRoute值要与workers.properties文件中定义的条目worker.tomcat1保持一致。
4.Tomcat2配置
1 修改配置文件server.xml
<Server port="8006" shutdown="SHUTDOWN">
<Connector port="8081" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8444" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8010"
enableLookups="false" redirectPort="8444" protocol="AJP/1.3" />
上面标注红色的端口值不能与Tomcat1相同,在同一个IP环境中需要保持唯一。
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
jvmRoute值要与workers.properties文件中定义的条目worker.tomcat2保持一致。
5.session复制配置
还是在tomcat的server.xml中
engine节点下添加
最终要的一个
在web项目的web.xml中添加<distributable/>不添加就不会去复制session
最后测试:
建web项目在index.jsp中内容:
orther.jsp中取出存在session中的username值,看是否有值显示
正确显示为:
session attribute:xiaomei
SessionId:8C0113C471EF5ED1989CAFCC4CC81807.tomcat1
然后down掉当前tomcat点击跳转,看是否会显示:
session attribute:xiaomei
SessionId:8C0113C471EF5ED1989CAFCC4CC81807.tomcat2
则配置成功!
附上tomcat-connectors-1.2.37-src\conf\workers.properties
Apache2.2:http://archive.apache.org/dist/httpd/binaries/win32/
tomcat-connectors-1.2.37:http://apache.etoak.com/tomcat/tomcat-connectors/jk/source/jk-1.2.28/tomcat-connectors-1.2.28-src.zip
JK2 1.2:http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-connectors/jk/binaries/
端口设置
Apache 80
Tomcat1 8005 8080 8443 8009
Tomcat2 8006 8081 8444 8010
1.解压jk2将mod_jk.so放在Apache2.2\modules目录下
2.配置apache
打开httpd.conf对应位置添加
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkMountFile conf/urimap.properties
增加配置文件workers.properties
在apache目录conf创建两个文件workers.properties,内容如下
worker.list=router #配置请求处理server 这里可以配置多个server
参考:http://wenku.baidu.com/view/5a135db91a37f111f1855b7a.html
# Define the LB worker
worker.router.type=lb
worker.router.balance_workers=tomcat1,tomcat2 #指定分担请求的server列表,用逗号分隔
#设置用于负载均衡的server的session可否共享这里如果设置为0在复制session的时候tomcat会报错,但可以进行复制,如果设置为1就没有错误
worker.router.sticky_session=1
# Define 1 real tomcat using ajp13
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8009
worker.tomcat1.lbfactor=1
# Define another tomcat using ajp13
worker.tomcat2.type=ajp13
worker.tomcat2.host=localhost
worker.tomcat2.port=8010
worker.tomcat2.lbfactor=1
增加配置文件urimap.properties
在apache目录conf创建两个文件workers.properties,内容如下
/*.jsp=router #表示所有的jsp文件都由router这个server处理
/*/servlet/*=router
/cluster/*=router
!/*.gif=router #所有以.gif结尾的请求都不由controller这个server处理
这里的"!”类似于java中的"!”,是“非”的意思
把tomcat应用程序的访问URI匹配到jk2的工作条目router。
3.Tomcat1配置
1 修改配置文件server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
jvmRoute值要与workers.properties文件中定义的条目worker.tomcat1保持一致。
4.Tomcat2配置
1 修改配置文件server.xml
<Server port="8006" shutdown="SHUTDOWN">
<Connector port="8081" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8444" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8010"
enableLookups="false" redirectPort="8444" protocol="AJP/1.3" />
上面标注红色的端口值不能与Tomcat1相同,在同一个IP环境中需要保持唯一。
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
jvmRoute值要与workers.properties文件中定义的条目worker.tomcat2保持一致。
5.session复制配置
还是在tomcat的server.xml中
engine节点下添加
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6"> <Manager className="org.apache.catalina.ha.session.BackupManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="6"/> <!--有人说DeltaManager稳定性高于BackupManager具体不清楚 <Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/> --> <Channel className="org.apache.catalina.tribes.group.GroupChannel"> <Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="3000"/> <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="5001" selectorTimeout="100" maxThreads="6"/> <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"> <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> </Sender> <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> </Channel> <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/> <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/> <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/" watchEnabled="false"/> <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/> <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/> </Cluster>
最终要的一个
在web项目的web.xml中添加<distributable/>不添加就不会去复制session
最后测试:
建web项目在index.jsp中内容:
<body> <center> <h1> <% session.setAttribute("username","xiaomei"); out.println("</hr>"); out.println("session attribute:"+session.getAttribute("username")); out.println("SessionId:"+session.getId()); out.println("</hr>"); %> </h1> <a href="other.jsp">跳转</a> </center> </body>
orther.jsp中取出存在session中的username值,看是否有值显示
正确显示为:
session attribute:xiaomei
SessionId:8C0113C471EF5ED1989CAFCC4CC81807.tomcat1
然后down掉当前tomcat点击跳转,看是否会显示:
session attribute:xiaomei
SessionId:8C0113C471EF5ED1989CAFCC4CC81807.tomcat2
则配置成功!
附上tomcat-connectors-1.2.37-src\conf\workers.properties
# 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_timeouts to N and the errors are # occuring equally distributed over time, you will # tolerate N/2 errors per minute. If they occur in a burst # you will tolerate N errors. # Since: 1.2.24 worker.balancer.max_reply_timeouts=10 # Now we add members to the load balancer # First member is "node1", most # attributes are inherited from the # template "worker.template". worker.balancer.balance_workers=node1 worker.node1.reference=worker.template worker.node1.host=localhost worker.node1.port=8109 # Activation allows to configure # whether this node should actually be used # A: active (use node fully) # D: disabled (only use, if sticky session needs this node) # S: stopped (do not use) # Since: 1.2.19 worker.node1.activation=A # Second member is "node2", most # attributes are inherited from the # template "worker.template". worker.balancer.balance_workers=node2 worker.node2.reference=worker.template worker.node2.host=localhost worker.node2.port=8209 # Activation allows to configure # whether this node should actually be used # A: active (use node fully) # D: disabled (only use, if sticky session needs this node) # S: stopped (do not use) # Since: 1.2.19 worker.node2.activation=A # Finally we put the parameters # which should apply to all our ajp13 # workers into the referenced template # - Type is ajp13 worker.template.type=ajp13 # - socket_connect_timeout: milliseconds, default=0 # Since: 1.2.27 worker.template.socket_connect_timeout=5000 # - socket_keepalive: boolean, default=false # Should we send TCP keepalive packets # when connection is idle (socket option)? worker.template.socket_keepalive=true # - ping_mode: Character, default=none # When should we use cping/cpong connection probing? # C = directly after establishing a new connection # P = directly before sending each request # I = in regular intervals for idle connections # using the watchdog thread # A = all of the above # Since: 1.2.27 worker.template.ping_mode=A # - ping_timeout: milliseconds, default=10000 # Wait timeout for cpong after cping # Can be overwritten for modes C and P # Using connect_timeout and prepost_timeout. # Since: 1.2.27 worker.template.ping_timeout=10000 # - connection_pool_minsize: number, default=connection_pool_size # Lower pool size when shrinking pool due # to idle connections # We want all connections to be closed when # idle for a long time in order to prevent # firewall problems. # Since: 1.2.16 worker.template.connection_pool_minsize=0 # - connection_pool_timeout: seconds, default=0 # Idle time, before a connection is eligible # for being closed (pool shrinking). # This should be the same value as connectionTimeout # in the Tomcat AJP connector, but there it is # milliseconds, here seconds. worker.template.connection_pool_timeout=600 # - reply_timeout: milliseconds, default=0 # Any pause longer than this timeout during waiting # for a part of the reply will abort handling the request # in mod_jk. The request will proceed running in # Tomcat, but the web server resources will be freed # and an error is send to the client. # For individual requests, the timeout can be overwritten # by the Apache environment variable JK_REPLY_TIMEOUT. # JK_REPLY_TIMEOUT since: 1.2.27 worker.template.reply_timeout=300000 # - recovery_options: number, default=0 # Bit mask to configure, if a request, which was send # to a backend successfully, should be retried on another backend # in case there's a problem with the response. # Value "3" disables retries, whenever a part of the request was # successfully send to the backend. worker.template.recovery_options=3
相关推荐
3. **集群配置**:Apache2和Tomcat6的集群配置涉及到多个层面。首先,要在Apache2中启用mod_jk,并配置JKWorkers文件,定义每个Tomcat实例(worker)的属性,如IP地址、端口等。然后,需要在Apache的虚拟主机配置中...
Apache2.2与Tomcat6集群配置教程 在IT行业中,服务器集群是一种常见的技术,用于提高系统的可用性和可扩展性。本教程将详细介绍如何在Apache2.2与Tomcat6环境下搭建集群,以实现负载均衡和高可用性。Apache作为前端...
【Tomcat6集群和负载均衡】是Web服务器和应用程序服务器扩展和提高可用性的关键技术。Tomcat作为Apache基金会的Java Servlet容器,常常需要处理高并发请求,集群和负载均衡的实现可以有效解决这个问题。 集群是一种...
标题中的"memcached+tomcat6集群1.9.jar"提到了两个关键概念:Memcached和Tomcat集群,以及它们的版本号1.9。这表明我们正在处理一个与使用Memcached缓存服务来增强Tomcat 6集群性能相关的Java应用程序。 Memcached...
4. **Tomcat集群配置** - 需要在每台Tomcat服务器的`conf/server.xml`中配置Engine、Host和Context,以便支持集群环境。这通常涉及到定义一个`Cluster`元素,以及设置`sessionIDManager`和`Manager`。 - 同时,每...
1. **反向代理**:Apache2作为前端负载均衡器,接收用户请求,然后通过mod_proxy将请求转发到Tomcat集群中的某个实例。 2. **健康检查**:Apache2可以定期检查后端Tomcat实例的健康状态,如果发现某个实例不可用,...
此配置中包含是3个tomcat集群, 安装步骤大概如下: 1:安装httpd-2.2.17-win32-x86-no_ssl.msi 2:启动 apache-tomcat-6.0.36-windows-x86-1 apache-tomcat-6.0.36-windows-x86-2 apache-tomcat-6.0.36-windows-x86...
无意间看到tomcat 6集群的内容,就尝试配置了一下,还是遇到很多问题,特此记录。apache服务器和tomcat的连接方法其实有三种:JK、http_proxy和ajp_proxy。本文主要介绍最为常见的JK。 环境:PC2台:pc1(IP 192.168....
首先,了解Tomcat集群的基础知识。集群是通过将多个独立的Tomcat实例连接在一起,形成一个整体,共同处理请求,提高系统性能和可用性。在Tomcat中,可以通过两种方式实现集群:基于网络的广播(JVMRoute)和基于内存...
Tomcat6集群 + Apache + Nginx 均衡负载 以及apache 的ab进行压力测试的方法
首先,要理解Tomcat集群的基本概念。集群是一种通过多台服务器分担负载、提高服务可用性的技术。在Tomcat中,集群可以实现session复制,使得当一台服务器故障时,其他服务器能够接管其工作,保持服务不间断。此外,...
Tomcat7 集群配置 Tomcat7 集群配置是指将多个 Tomcat 服务器组合成一个集群,以提高系统的可用性和可扩展性。在这个配置中,Session 复制机制是一个非常重要的部分,它可以确保在集群中的每个节点都可以访问到同一...
2. **配置通信机制**:Tomcat集群中的节点需要相互通信,这通常通过两种方式实现:共享内存(适用于同一台物理机上的多个Tomcat实例)和基于网络的通信(如JMS,适用于跨网络的节点)。 3. **共享session**:为了...
【标题】:“Tomcat集群配置” 在Web应用的高可用性和可扩展性需求日益增长的今天,Tomcat集群成为了一个重要的解决方案。Tomcat集群能够通过负载均衡和故障转移来提高服务的稳定性和性能。以下是对Tomcat集群配置...
本文将详细介绍如何在一机双Tomcat环境下搭建Apache+Tomcat集群,并深入解析其中的关键配置和技术细节。 #### 二、Apache+Tomcat集群的优势 1. **高可靠性(HA)**:通过集群管理软件实现在主服务器发生故障时,备份...
apache tomcat负载集群,appache负载,tomcat负载
nginx 配置tomcat8集群
【标题】:Tomcat5集群中的SESSION复制详解 【描述】:本文将深入探讨Tomcat5在集群环境下的SESSION复制机制,以及如何确保SESSION的持久性和集群中的无缝切换。 【标签】:Tomcat5,复制,集群,SESSION 在...