Nginx+tomcat+memcached-session-manager compose a simple cluster

Source: Internet
Author: User

1. Build the Environment

192.168.29.128 (luxh-01.com) installation Nginx, reference http://www.cnblogs.com/luxh/p/4067038.html

192.168.29.129 (luxh-02.com) installs Tomcat and memcached

192.168.29.130 (luxh-03.com) installs Tomcat and memcached

2, installation memcached

1) install directly with Yum

[Email protected]yuminstall memcached

2) Start memcached, the default boot port is 11211

[Email protected] ~]# memcached-u memcached

-U Specify user

3) test whether the start is successful

[Email protected]127.0. 0.1 11211

3, Installation Tomcat7

Reference: http://www.cnblogs.com/luxh/p/3188736.html

4. Add Memcached-session-manager related jar to Tomcat

Place the following jar in the Lib directory of the Tomcat installation path

memcached-session-manager-1.8.2. jarmemcached-session-manager-tc7-1.8.2. jarspymemcached- 2.11.1.jar

Note that the version of Tomcat is different, the jar version is also different, specifically refer to Http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration

5. Add serializers related jars to the web App

The serialization is implemented here using Kryo-serializer.

The project uses MAVEN to add dependencies directly

<dependency>    <groupId>de.javakaffee.msm</groupId>    <artifactId> msm-kryo-serializer</artifactid>    <version>1.8.0</version>    <scope> Runtime</scope></dependency>

If you do not use MAVEN, add the following jar to the project yourself

msm-kryo-serializer-1.8.0. jarkryo-serializers-0.11. jarkryo-1.04.jarasm-3.2. jarreflectasm-1.01. jarminlog-1.2.jarjsr305-1.3.9. jarannotations-1.3.9. Jar

6. Configuring Memcached-session-manager in Tomcat

Include the following in the Tomcat context.xml file (<Context></Context> tag).

Non-sticky session configuration, two memcached servers.

<className= "De.javakaffee.web.msm.MemcachedBackupSessionManager"     Memcachednodes= "n1:luxh-02.com:11211,n2:luxh-03.com:11211"    sticky= "false"     sessionbackupasync= "false"    requesturiignorepattern= ". *\. ( ICO|PNG|GIF|JPG|CSS|JS) $ "    transcoderfactoryclass=" De.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory "    />

7. Configure Nginx

1) Add the contents of the HTTP node in the nginx.conf file

Upstream luxh-01.com {            server luxh-02.com:8080;            Server luxh-03.com:8080; }

2) Add the contents of the server node in the nginx.conf file

Location/{            Proxy_pass http://luxh-01.com;            Proxy_set_header X-real-ip $remote _addr; }

8. Deploy the application separately to the Tomcat server.

1) Start memcached service

2) Start Tomcat

3) Start Nginx

9. Direct access to Http://luxh-01.com/webapp (the project I deployed is accessed through WebApp)

Nginx+tomcat+memcached-session-manager compose a simple cluster

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.