The session tomcat server (memcache)

#: Tomcat in each node to install memcached 

[root @ node1 ~] # yum  install memcached - the y- 

#: tomcat download the required jar package (where to find software in the video) 

[root @ node1 ~] # wget HTTP: // repo1.maven.org/maven2/de/javakaffee/msm/memcached-session-manager/2.3.2/memcached-session-manager-2.3.2.jar 
[root @ node1 ~] # wget HTTP: // repo1.maven .org / Maven2 / de / javakaffee / MSM / the session-memcached-Manager-TC8 / 2.3.2 / memcached-the session-Manager-tc8-2.3.2.jar 
[root @ node1 ~] # wget HTTP: // repo1. maven.org/maven2/net/spy/spymemcached/2.12.3/spymemcached-2.12.3.jar 
[root @ node1 ~] # wget HTTP://repo1.maven.org/maven2/de/javakaffee/msm/msm-kryo-serializer/2.3.2/msm-kryo-serializer-2.3.2.jar
[root@node1 ~]# wget
http://repo1.maven.org/maven2/de/javakaffee/kryo-serializers/0.45/kryo-serializers-0.45.jar [root@node1 ~]# wget http://repo1.maven.org/maven2/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar [root@node1 ~]# wget http://repo1.maven.org/maven2/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar [root@node1 ~]# wget http://repo1.maven.org/maven2/org/ow2/asm/asm/5.2/asm-5.2.jar [root@node1 ~]# wget http://repo1.maven.org/maven2/org/objenesis/objenesis/2.6/objenesis-2.6.jar #: The jar package into the lib directory [the root @ node1 ~] # CP -R & lt * .jar / usr / local / Tomcat / lib / #: modify the configuration of [the root @ node1 ~] # VI / usr / local / Tomcat / the conf / context.xml <WatchedResource> the WEB-INF / the web.xml </ WatchedResource> <WatchedResource>} $ {catalina.base /conf/web.xml </ WatchedResource> <Manager className = " de.javakaffee.web.msm.MemcachedBackupSessionManager " memcachedNodes = " N1: 192.168.5.101: 11211, N2: 192.168.5.102: 11211 " failoverNodes = "n1" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/> [root@node2 ~]# vim /usr/local/tomcat/conf/context.xml <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:192.168.5.101:11211,n2:192.168.5.102:11211"= failoverNodes" N2 " requestUriIgnorePattern = " .. * \ (Ico | PNG | GIF | JPG | CSS | JS) $ " transcoderFactoryClass = " de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory " />

Note: This is a cross-Mem storage memory 1 to 2, 2 to the memory 1. When the hang mem 2, the existence of only 1 to 1. Each tomcat itself also has session, only to find on their own when not mem


#: jar packets to all nodes 2 a copy of the
[root @ node1 ~] # scp -r / usr / local / tomcat / lib / * 192.168.5.102:/usr/local/tomcat/lib/ .jar

#: start
#: test

 

NON- Sticky mode 
principle 
from MSM 1.4 after 0.05 begun to support NON- Sticky mode. 
Tomcat session for the transit Session, n1-based session, n2 is the backup session. Generating new Session will be sent to the master, the memcached standby, and clears the local Session. 
offline n1, n2 positive. Again on the line n1, n2 remains Session primary storage node. 



# Configure Tomcat 


[Tomcat the root @ node1] # Vim the conf / context.xml
 <Manager className = " de.javakaffee.web.msm.MemcachedBackupSessionManager "  
        memcachedNodes = " N1: 192.168.5.101: 11211, N2: 192.168.5.102: 11211 " 
        Sticky = " false " 
        sessionBackupAsync = " false " 
        lockingMode="uriPattern:/path1|/path2"
        requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>



#:测试

 

 

redis configuration (note install redis here lib library of relevant you can, do not install tomcat related) 


#: Download redis 

[root @ node1 tomcat] # yum  install redis - the y- 

#: Modify Redis listen address 

[root @ node1 tomcat] # Vim / etc / redis.conf 
the bind 0.0 . 0.0 

#: modify the configuration file (tomcat all point to the same backend the Redis) 

[the root @ node1 tomcat] # Vim the conf /context.xml 
<Manager className = "de.javakaffee .web.msm.MemcachedBackupSessionManager "
        memcachedNodes =" Redis: //192.168.5.101: 6379 "
        Sticky =" false "
        sessionBackupAsync =" false "
        lockingMode =" uriPattern: / path1 | / path2 "
        requestUriIgnorePattern =" * \..(ico|png|gif|jpg|css|js)$"
        transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>

 

Guess you like

Origin www.cnblogs.com/maxuebin/p/11449374.html