Tomcat uses memcache for session sharing

Source: Internet
Author: User

This article describes how tomcat uses memcache to solve session sharing. I hope this method will be helpful to you.

1. Description
It mainly uses the memcached-session-manager open-source tomcat plug-in to change the original session storage mechanism of tomcat, and stores the session storage in the distributed cache memcache to achieve session sharing.

2. Download the installation package
Jar packages required by memcache-session-manager on tomcat6
This is to put a zip package of the official msm jar for easy download and use.
Official memcache-session-manager
For memcache download, see install memcache.

3. Environment Description
System: centos 5.x
Required software:
Tomcat-6.0.20
Memcache-session-manager-1.4.0

4. installation and configuration steps
4.1 install memcache
4.2 install tomcat 6 See linux nginx Server Load balancer/image cache + tomcat cluster/session sharing part 2
4.3 install and configure msm
Decompress the downloaded msm-atat6-all-dependence.zip file and copy the extracted jar package to the tomcat6/lib directory.
Modify the tomcat6/conf/context. xml file
Add the following configuration in </WatchedResource>:

<Manager className = "de. javakaffee. web. msm. MemcachedBackupSessionManager"
MemcachedNodes = "n1: localhost: 11211"
RequestUriIgnorePattern = ". *. (png | gif | jpg | css | js) $"
TranscoderFactoryClass = "de. javakaffee. web. msm. serializer. kryo. KryoTranscoderFactory"
/>
Start tomcat and you will find that the log contains the log for initializing the msm. If no exception occurs, the plug-in is successfully installed.
Note: The plug-in packages of tomcat5, tomcat6, and tomcat7 are different. Please read the official memcache-session-manager wiki for details. A Configuration article on the Internet may be the configuration of tomcat5, the session sharing is abnormal after being configured on Tomcat 6.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.