今天研究了下TOMCAT集群,遇到問題,望解答!
環(huán)境是一樣的2臺(tái)機(jī)器(下面用tomcat1,tomcat2來表示這兩臺(tái)機(jī)器)
按照官方網(wǎng)站的文檔配置,2個(gè)服務(wù)器都能正常起來。而且都監(jiān)聽到了對(duì)方的存在,下面是輸出信息:
信息: 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/> 已經(jīng)配置了
使用同一個(gè)IE窗口訪問2個(gè)服務(wù)得到的SESSION ID不同,在tomcat1保存一個(gè)session attribute,在tomcat2上沒有,得到結(jié)果,配置失敗。SESSION沒有被復(fù)制到另一個(gè)服務(wù)。望高手幫幫忙!
我沒有做負(fù)載均衡,只做了集群。
以下是tomcat官網(wǎng)上的原話,不知道是不是我沒理解明白,誰能再給說明下:
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.
兩個(gè)TOMCAT的server.xml唯一不同的地方就是Receiver的監(jiān)聽端口,一個(gè)是4000一個(gè)是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>
FeedBack:
2007-11-24 20:02 | wangzm
所有你放在session里面的對(duì)象要實(shí)現(xiàn)序列化接口。這個(gè)是為了內(nèi)存復(fù)制。
還有就是如果放到一臺(tái)機(jī)器上,端口別忘記了修改。 回復(fù) 更多評(píng)論
還有就是如果放到一臺(tái)機(jī)器上,端口別忘記了修改。 回復(fù) 更多評(píng)論
只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。 | ||
![]() |
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
28 | 29 | 30 | 31 | 1 | 2 | 3 | |||
4 | 5 | 6 | 7 | 8 | 9 | 10 | |||
11 | 12 | 13 | 14 | 15 | 16 | 17 | |||
18 | 19 | 20 | 21 | 22 | 23 | 24 | |||
25 | 26 | 27 | 28 | 29 | 30 | 1 | |||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
常用鏈接
留言簿(1)
隨筆檔案
搜索
最新評(píng)論

- 1.?re: tomcat訪問網(wǎng)絡(luò)映射驅(qū)動(dòng)器被windows2003限制
- 搜一下”通過jcifs實(shí)現(xiàn)java訪問網(wǎng)絡(luò)共享文件“,用smb協(xié)議的java實(shí)現(xiàn)類包訪問沒有問題的。
- --阿湘哥哥
- 2.?re: 往網(wǎng)絡(luò)映射磁盤寫文件遇見的怪事
-
@么
windows2003的安全機(jī)制不允許程序往映射網(wǎng)絡(luò)磁盤里寫文件。
你直接使用網(wǎng)絡(luò)路徑寫就可以了 - --dd.zhang
- 3.?re: 往網(wǎng)絡(luò)映射磁盤寫文件遇見的怪事
- 大哥你們?cè)趺唇鉀Q的 我也遇到了 沒有思路啊
- --么
- 4.?re: tomcat訪問網(wǎng)絡(luò)映射驅(qū)動(dòng)器被windows2003限制
- 評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
- --dd.zhang
- 5.?re: tomcat訪問網(wǎng)絡(luò)映射驅(qū)動(dòng)器被windows2003限制
- 評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
- --dd.zhang