Memcache-No.02 Tomcat集群+Memcache实现Session共享

1、前期准备:

    一台Nginx服务器部署在192.168.6.133上

    一台Memcache缓存服务器部署在192.168.6.133上

    两台Tomcat服务器分别部署在192.168.6.110(Tomcat01)和192.168.6.111(Tomcat02)上

 

2、修改Tomcat配置

    1)Tomcat01:

    修改context.xml文件:配置对memcache连接,将缓存写入memcache中实现共享

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
        memcachedNodes="n1:192.168.6.133:11211"
        requestUriIgnorePattern=".*/.(png|gif|jpg|css|js)$"
        sessionBackupAsync="false"
        sessionBackupTimeout="100"
        transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
        copyCollectionsForSerialization="false"
      />

    修改server.xml文件:

#端口号1
<Server port="30004" shutdown="SHUTDOWN">
#端口号2
<Connector port="30005" protocol="HTTP/1.1"
               maxHttpHeaderSize="8192"
               connectionTimeout="20000"
               maxThreads="2048"
               minSpareThreads="100"
               maxSpareThreads="200"
               enableLookups="false"
               acceptCount="500"
               disableUploadTimeout="true"
               redirectPort="8443" URIEncoding="UTF-8"  />
#端口号3
<Connector port="30006" protocol="AJP/1.3" redirectPort="8443" />
#JVM名称修改
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

 

 2)Tomcat02:

    修改context.xml文件:配置对memcache连接,将缓存写入memcache中实现共享

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
        memcachedNodes="n1:192.168.6.133:11211"
        requestUriIgnorePattern=".*/.(png|gif|jpg|css|js)$"
        sessionBackupAsync="false"
        sessionBackupTimeout="100"
        transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
        copyCollectionsForSerialization="false"
      />

    修改server.xml文件:

#端口号1
<Server port="40004" shutdown="SHUTDOWN">
#端口号2
<Connector port="40005" protocol="HTTP/1.1"
               maxHttpHeaderSize="8192"
               connectionTimeout="20000"
               maxThreads="2048"
               minSpareThreads="100"
               maxSpareThreads="200"
               enableLookups="false"
               acceptCount="500"
               disableUploadTimeout="true"
               redirectPort="8443" URIEncoding="UTF-8"  />
#端口号3
<Connector port="40006" protocol="AJP/1.3" redirectPort="8443" />
#JVM名称修改
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm2">

3)在Tomcat的lib文件添加相关包,如 Annex-No.01 Tomcat集群+Memcache实现Session共享 中lib包

你可能感兴趣的:(Memcache-No.02 Tomcat集群+Memcache实现Session共享)