tomcat session 共享

server.xml, web.xml

tomcat 6 -tomcat 7粘贴下面的配置文件

server.xml

channelSendOptions="4">

expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>


address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
address="auto"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>





filter=""/>

tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>



tomcat 8.x

channelSendOptions="4">

expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>


address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
address="192.168.2.55"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>






filter=""/>

tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>


web.xml

在最后一行加上 如图

1.环境注意事项

a.多个物理机的时间要一致

b.tomcat 版本要一致

c.多个物理机之间要能够互相通信

d.nginx的ip hash这个配置不能连用,用这个的话会造成会话粘性,这样session就不会共享了,需要在nginx的配置上去掉这个配置项

2.配置文件说明

在上面的配置文件中绿色标识的地方,receiver标签里面的address一定要配置成本机的实际ip地址 不能配置auto,和127.0.0.1和localhost

channelSendOptions 这个配置是来控制session 同步复制还是异步 



你可能感兴趣的:(tomcat配置)