在你的Tomcat8容器中来运行session复制,应该完成以下步骤
- All your session attributes must implement
java.io.Serializable
- 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 - 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 - Make sure your
web.xml
has the<distributable/>
element - 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 - Make sure that all nodes have the same time and sync with NTP service!
- Make sure that your loadbalancer is configured for sticky session mode.
- 1、所有的session属性必须实现序列化接口
- 2、在server.xml中被解除注释的Cluster标签
- 3、如果你定义了集群values,你确定有
ReplicationValve
值在server.xml中的Cluster元素中有定义。 - 4、如果你的Tomcat实例运行在同一台机器上,你要保证每个Tomcat的TCP监听端口属性值唯一,可用端口范围在4000到4100
- 5、确定在web.xml 中有
<distributable/>
元素 - 6、如果你使用mod_jk插件,要保证在
Engine
元素中有jvmRoute属性并且jvmRoute属性值在workers.properties中有定义。 - 7、确保所有节点具有相同的时间和NTP服务同步!
- 8、确保你的负载平衡器配置为sticky会话模式。
负载均衡可以通过很多技术来实现,如Load Balancing(负载平衡)的章节所看到的。
Note: Remember that your session state is tracked by a cookie, so your URL must look the same from the out side otherwise, a new session will be created.
注:记住你的会话状态是由一个cookie跟踪,所以你的URL必须从外面同一个浏览器请求,否则看起来一样其实一个新的会话将被创建。
集群支持目前需要JDK 1.5或更高版本。
The Cluster module uses the Tomcat JULI logging framework, so you can configure logging through the regular logging.properties file. To track messages, you can enable logging on the key:org.apache.catalina.tribes.MESSAGES