windows7+tomcat7+nginx1.11.3 +memcached
测试的环境是windows7+tomcat7+nginx1.11.3 +memcached
安装方法网上很多就不多说了。
1.session共享需要这几个jar 包
下载地址
http://download.csdn.net/detail/scau_rich/7791157
2.解压到tomcat lib目录下面 两个tomcat都需要。
3.新建JSP页面放入tomca webapps/root目录下面(两个tomcat都要放)
<%@page language="java"%>
<html>
<body>
<h1><font color="red">Session serviced by tomcat</font></h1>
<table aligh="center" border="1">
<tr>
<td>Session ID</td>
<td><%=session.getId() %></td>
<% session.setAttribute("abc","abc");%>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
<html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
4.在tomcat的conf文件夹里面配置content.xml 两个tomcat 都需要配置
`
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sessionBackupAsync="false"
sessionBackupTimeout="100"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
copyCollectionsForSerialization="false" />
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
`
5.运行tomcat .nginx memcahced
6.打开浏览器。按F5刷新
看到这个说明session共享成功了