posts - 11,  comments - 18,  trackbacks - 0
今天研究了下TOMCAT集群,遇到问题,望解答!  
环境是一样的2台机器(下面用tomcat1,tomcat2来表示这两台机器)  
按照官方网站的文档配置,2个服务器都能正常起来。而且都监听到了对方的存在,下面是输出信息:  
信息:       Verification       complete.       Member       disappeared[org.apache.catalina.tribes.membership.MemberImpl[tcp://WDGJ-14:4001,WDGJ-14,4001,       alive=1608998,id={101       20       -85       1       -96       113       79       34       -116       24       -43       -93       27       -49       -87       44       },       payload={},       command={},       domain={},       ]]  
web.xml的 <distributable/> 已经配置了

使用同一个IE窗口访问2个服务得到的SESSION       ID不同,在tomcat1保存一个session       attribute,在tomcat2上没有,得到结果,配置失败。SESSION没有被复制到另一个服务。望高手帮帮忙!  
我没有做负载均衡,只做了集群。
以下是tomcat官网上的原话,不知道是不是我没理解明白,谁能再给说明下:
1.All   your   session   attributes   must   implement   java.io.Serializable  
2.Uncomment   the   Cluster   element   in   server.xml  
If   you   have   defined   custom   cluster   valves,   make   sure   you   have   the   ReplicationValve   defined   as   well   under   the   Cluster   element   in   server.xml  
3.If   your   Tomcat   instances   are   running   on   the   same   machine,   make   sure   the   tcpListenPort   attribute   is   unique   for   each   instance,   in   most   cases   Tomcat   is   smart   enough   to   resolve   this   on   it 's   own   by   autodetecting   available   ports   in   the   range   4000-4100  
4.Make   sure   your   web.xml   has   the   <distributable/>   element   or   set   at   your   <Context   distributable= "true "   />  
5.If   you   are   using   mod_jk,   make   sure   that   jvmRoute   attribute   is   set   at   your   Engine   <Engine   name= "Catalina "   jvmRoute= "node01 "   >   and   that   the   jvmRoute   attribute   value   matches   your   worker   name   in   workers.properties  
6.Make   sure   that   all   nodes   have   the   same   time   and   sync   with   NTP   service!  
7.Make   sure   that   your   loadbalancer   is   configured   for   sticky   session   mode.  

两个TOMCAT的server.xml唯一不同的地方就是Receiver的监听端口,一个是4000一个是4001  
server.xml文件如下:  
<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=   "80   "       protocol=   "HTTP/1.1   "      
                                                            connectionTimeout=   "20000   "      
                                                            redirectPort=   "8443   "       />  
                <Connector       port=   "8009   "       protocol=   "AJP/1.3   "       redirectPort=   "8443   "       />  

                <Engine       name=   "Catalina   "       defaultHost=   "localhost   ">  

    <Cluster       className=   "org.apache.catalina.ha.tcp.SimpleTcpCluster   "  
                                                    channelSendOptions=   "8   ">  

                        <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=   "4000   "  
                                                                        autoBind=   "100   "  
                                                                        selectorTimeout=   "5000   "  
                                                                        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   "/>  
                        </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>  

                        <Realm       className=   "org.apache.catalina.realm.UserDatabaseRealm   "  
                                                    resourceName=   "UserDatabase   "/>  

                        <Host       name=   "localhost   "           appBase=   "webapps   "  
                                                unpackWARs=   "true   "       autoDeploy=   "true   "  
                                                xmlValidation=   "false   "       xmlNamespaceAware=   "false   ">  

                        </Host>  
                </Engine>  
        </Service>  
</Server>  
posted on 2007-11-08 15:14 dd.zhang 阅读(1192) 评论(1)  编辑  收藏

FeedBack:
# re: 关于tomcat6集群的问题
2007-11-24 20:02 | wangzm
所有你放在session里面的对象要实现序列化接口。这个是为了内存复制。
还有就是如果放到一台机器上,端口别忘记了修改。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

常用链接

留言簿(1)

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜