Environment centos6.7, download and install the necessary software: Yum-y install Epel-release (TOMCAT7 on this source, TOMCAT7 is now the mainstream version)
Yum-y install tomcat direct download TOMCAT7, yum-y install Java-1.7.0-openjdk-devel (Tomcat needs to run on a Java virtual machine)
Vim/etc/tomcat/server.xml Modifying a configuration file
unpackwars= "true" autodeploy= "true" > <context path= "" docbase= "/data/webapps" reloadable= "true" > <manager classname= " De.javakaffee.web.msm.MemcachedBackupSessionManager " memcachednodes=" n1:192.168.238.250:11211,n2 : 192.168.238.251:11211 " failovernodes=" N2 " requesturiignorepattern=". *\. ( ICO|PNG|GIF|JPG|CSS|JS) $ " transcoderfactoryclass=" De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory "/> </Context> </ Host>
The above words are not to be repaid, it is to put a map
Customized a virtual host:
Added Context:<context path= "" docbase= "/data/webapps" reloadable= "true" on this virtual host >
The key is the manager segment:
Take a globally unique name for the Manager: <manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
What memcached server nodes are defined: memcachednodes= "n1:192.168.238.250:11211,n2:192.168.238.251:11211"
Define an alternate node: failovernodes= "N2"
For those request URL ignore: requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ "
Fixed format: transcoderfactoryclass= "De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"/>
Define the default virtual host as Web.com:
Jvmroute= "Tomcata" is added jvmroute= "Tomcata" in the session ID of the request web.com, this experiment can not be added
Create a page resource: Mkdir-p/data/webapps/{web-inf,classes,lib} cd/data/webapps/vim index.jsp
JSP page resources are as follows
<%@ page language= "java"%>
Put a picture:
Download the following packages: javolution-5.5.1 memcached-session-manager-1.8.2 memcached-session-manager-tc7-1.8.2
msm-javolution-serializer-1.8.2 spymemcached-2.10.2 These package functions: Java through the memcached implementation session management
Above these several packages: Https://github.com/magro/memcached-session-manager/wiki/SetupAndConfiguration
Put the top several bags in the/usr/share/tomcat/lib/directory (note that the above bags are not wrong, this is a potential pit)
The versions of these packages must be right, I've been on this one-day pit, if your is tomcat8, corresponding to the memcached-session-manager-tc8-1.8.2
Two memcached are placed on both Tomcat and downloaded using yum-y install memcached.
Put the above steps on the Tomcata step, TOMCATB on the TOMCATB, the JSP page in the resource Tomcata changed to Tomcatb,red to Blue
Set up a nginx front end load balancer, start memcached, start Tomcat, start Nginx, go to browser verification
Validation succeeds, Session ID remains the same
Using memcached for Tomcat cluster session sharing