apache+tomcat集群遇到的问题

版权声明:创作不易,转载请声明博客地址,谢谢! https://blog.csdn.net/Is_I_black/article/details/80196359
问题1.
前提:
web.xml下要加<distributable/>
在tomcat的context.xml的context标签属性加入distributable="true"(未尝试)
遇见问题:
在登陆时发现如下异常:

Caused by: java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute memberAdmin

解决方法:找到对应key-value下的value的类进行序列化。

问题2.
在server.xml配置集群指令时,加入如下:

<!-- 集群配置 -->
<!--<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"
bind="127.0.0.1"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4002"
selectorTimeout="100"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" timeout="60000"/>
</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;"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>-->

解决方法:

<!-- 经测试如下集群配置本机生效,
如上注释的配置集群能生效但是ip定向且session不能共享,挂了一个服务器后,session会清除需要重新登录
-->
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
</Cluster>

注释的集群配置可能是tomcat版本号的影响,没有深入研究过,我目前使用的tomcat版本为apache-tomcat-7.0.69

猜你喜欢

转载自blog.csdn.net/Is_I_black/article/details/80196359