我们有在 Tomcat 上运行的网站。其中一些是集群的(通常是一个集群中的两个节点),并且一切正常。
然而,我们有一对 session 没有正确复制,即使配置看起来与我们的其他(工作)安装相似。
当我通过 JMX 检查 Tomcat 节点时,我看到工作站点和非工作站点的 Cluster.modelerType 都设置为 org.apache.catalina.ha.tcp.SimpleTcpCluster。
但是,当我查看管理器时,我看到为工作节点加载了 DeltaManager,但为不工作的节点加载了 StandardManager。
web.xml 确实设置了“
这是来自 server.xml (Tomcat 7.0.42) 的片段
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.3.4"
port="23810"
frequency="500"
dropTime="3000"
/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="192.168.1.144"
/>
</Channel>
</Cluster>
配置的哪一部分可能导致 SimpleTcpCluster 处于事件状态,但 StandardManager 处于使用状态,您知道吗?
最佳答案
这是创建管理器的 StandardContext 中的代码(取自 Tomcat 8,但它并没有真正改变许多版本)
// Acquire clustered manager
Manager contextManager = null;
Manager manager = getManager();
if (manager == null) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("standardContext.cluster.noManager",
Boolean.valueOf((getCluster() != null)),
Boolean.valueOf(distributable)));
}
if ( (getCluster() != null) && distributable) {
try {
contextManager = getCluster().createManager(getName());
} catch (Exception ex) {
log.error("standardContext.clusterFail", ex);
ok = false;
}
} else {
contextManager = new StandardManager();
}
}
看来您检查的内容正确。此时,我会将我的 IDE 连接到 Tomcat 实例,并使用远程调试逐步执行这部分代码,以找出为什么使用了错误的管理器。
关于tomcat - 加载标准管理器而不是 DeltaManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19599260/