nginx 负载均衡 tomcat 集群 memcached session 复制(共享)

准备工作:
将以下 jar 复制到 tomcat 目录下的 lib 目录下:
memcached-session-manager-1.6.1.jar
memcached-session-manager-tc7-1.6.1.jar
msm-javolution-serializer-1.6.1.jar
spymemcached-2.8.1.jar
javolution-5.4.3.1.jar

//********************************* nginx.conf
upstream jsp_server {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
ip_hash;
}
server {
listen 80;
server_name s.myechinese.com cas.myechinese.com;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://jsp_server;
}
}
//********************************* context.xml
< Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:127.0.0.1:11211" sticky="false" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory" />
//********************************* server.xml
在 Engine 节点添加 jvmRoute 属性
//*********************************
memcached-session-manager 提供几种 session 序列化方式,一定要根据你选择的序列化方式添加依赖的 jar 包.