首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 应用服务器 >

高手帮忙:tomcat集群可以了,但是不知道session复制成功没有?怎么做(有配置文件)

2012-12-23 
高手帮忙:tomcat集群可以了,但是不知道session复制成功没有?如何做(有配置文件) 我在一台机器上面配置了三

高手帮忙:tomcat集群可以了,但是不知道session复制成功没有?如何做(有配置文件)
 
我在一台机器上面配置了三个tomcat6和apache2.2的集群,并设置了粘性会话
 
集群已经配置成功了,可以访问应用,当刷新tomcat1的时候session总是不变(说明粘性ok),然后关闭tomcat1会跳转到tomcat2,session里面的值已经传过去了,但是sessionID的前面部分不一样。

在tomcat1的sessionId是:aaaaaaaaa.tomcat1
关闭之后跳转到了tomcat2服务器,到tomcat2显示sessionId 名称是
aaaaaaaaa.tomcat2

这样的情况对么?是不是说明session复制成功?(我认为没有成功?是不是应该叫做aaaaaaaaa.tomcat2就是成功了??)

我在网上找了很多帖子啊,都是问的这个问题,但是后面怎么解决的就没有下文了。。。。我把我的配置和书上的,网上的都比较了,没有出现问题哈,实在不知知道是不是对的,或者就是这样??


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tomcat1的配置文件如下:
<Server port="8005" shutdown="SHUTDOWN"> 
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> 
  <Listener className="org.apache.catalina.core.JasperListener" /> 
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
 
  <GlobalNamingResources> 
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
 
  <Service name="Catalina">  
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 
    <Engine name="Catalina" defaultHost="localhost"  jvmRoute="tomcat1">
 
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>   
      <Host name="192.168.1.108"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false"> 
  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="6">

          <Manager className="org.apache.catalina.ha.session.BackupManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"
                   mapSendOptions="6"/>     
          <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="4001"
                      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=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>

          <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.ClusterSessionListener"/>
        </Cluster> 
      </Host>
    </Engine>
  </Service>
</Server>

其余的tomcat2,3均和上面的差不多,但是
 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />


 <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
。。。
 <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4002"
                      selectorTimeout="100"
                      maxThreads="6"/>
.....
.....

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tomcat负载配置属性文件:

#server
worker.list = controller,stat1
#========tomcat1========
worker.tomcat1.port=8009
worker.tomcat1.host=192.168.1.108
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 5
#========tomcat2========
worker.tomcat2.port=8010
worker.tomcat2.host=192.168.1.108
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 5
#========tomcat3========
worker.tomcat3.port=8011
worker.tomcat3.host=192.168.1.108
worker.tomcat3.type=ajp13
worker.tomcat3.lbfactor = 5
worker.tomcat3.retries = 20
worker.stat1.type = status
#========controller,负载均衡控制器========
worker.controller.type=lb
worker.controller.balance_workers=tomcat1,tomcat2,tomcat3 
worker.controller.sticky_session=true 
#sworker.controller.sticky_session_force=1
 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
测试用的jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<html><head><title>Cluster App Test</title></head>
<body>
Server Info:
<%
out.println(request.getLocalAddr() + " : " + request.getLocalPort()+"<br>");%>
<%
  out.println("<br> ID<font color='green'> " + session.getId()+"</font><br>");
  session.setAttribute("a","abc");
  out.println("<br> ID<font color='green'> " +session.getCreationTime()+"</font><br>");
%> 
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[解决办法]
没有人看看么。。。
[解决办法]
我也正在做这个,纳闷着呢。。。集群做好了 ,但是session没有复制成功
[解决办法]
后来解决了没啊。。
[解决办法]
解决了,是一个机器上面的原因,换不同的机器实验一下

热点排行