Build a High-Performance cluster with Apache + Tomcat + session + memcache

Source: Internet
Author: User

I. Topology



II. Environment Installation

Install memcached's direct yum

[[Email protected] ~] # Yum-y install memcached

[[Email protected] ~] # Service memcached start

Starting memcached: [OK]

[[Email protected] ~] # SS-anlpt | grep memcached

Listen 0 128: 11211: * Users :( ("memcached", 262.16,27 ))

Listen 0 128 *: 11211 *: * Users :( ("memcached", 262.16,26 ))

[[Email protected] ~] #


Because Tomcat depends on the Java environment, install JDK first (Tomcat a B is the same)

[[Email protected] SRC] # rpm-IVH jdk-7u9-linux-x64.rpm

[[Email protected] SRC] # Vim/etc/profile. d/Java. Sh

Java_home =/usr/Java/jdk1.7.0 _ 09

Path = $ java_home/bin: $ path

Export java_home

[[Email protected] SRC] # source/etc/profile. d/Java. Sh


Install Tomcat

[[Email protected] SRC] # tar xf apache-tomcat-7.0.42.tar.gz-C/usr/local/

[[Email protected] SRC] # cd/usr/local/

[[Email protected] local] # ln-sv apache-Tomcat-7.0.42/tomcat

'Tomcat '-> 'apache-Tomcat-7.0.42 /'

[[Email protected] Tomcat] # Vim/etc/profile. d/tomcat. Sh

Export catalina_home =/usr/local/tomcat

Export Path = $ catalina_home/bin: $ path

[[Email protected] Tomcat] # source/etc/profile. d/tomcat. Sh

[[Email protected] Tomcat] # Catalina. Sh version # view the version

[[Email protected] Tomcat] # Catalina. Sh start # Start


Modify the tomcat configuration file (A and B are the same)

Configure session sharing memcache, which is placed under the Lib of two Tomcat servers.

Javolution-5.4.3.1.jar

Memcached-session-manager-1.8.1.jar

Memcached-session-manager-tc7-1.8.1.jar Z

Msm-javolution-serializer-1.8.1.jar

Spymemcached-2.10.2.jar


[[Email protected] Tomcat] # Vim CONF/context. xml

<Context>

<Manager classname = "De. javakaffee. Web. MSM. memcachedbackupsessionmanager"

Memcachednodes = "N1: 192.168.83.134: 11211"

Failovernodes = "N1"

Requesturiignorepattern = ". * \. (ICO | PNG | GIF | JPG | CSS | JS) $" transcoderfactoryclass = "De. javakaffee. Web. MSM. serializer. kryo. kryotranscoderfactory"

/>

</Context>

Provide a test page for Tomcat

#### Tomcat ##########

[[Email protected] Tomcat] # mkdir-PV/usr/local/tomcat/webapps/test/WEB-INF/{classes, lib}

[[Email protected] Tomcat] # Vim/usr/local/tomcat/webapps/test/index. jsp

<% @ Page Language = "Java" %>

<HTML>

<Head> <title> tomcata </title>

<Body>

<H1> <font color = "red"> tomcata.magedu.com </font>

<Table align = "center" border = "1">

<Tr>

<TD> session ID </TD>

<% Session. setattribute ("magedu.com", "magedu.com"); %>

<TD> <% = session. GETID () %> </TD>

</Tr>

<Tr>

<TD> created on </TD> <% = session. getcreationtime () %> </TD>

</Tr>

</Table>

</Body>

</Html>

~ ##### Tomcat B ##########

Mkdir-PV/usr/local/tomcat/webapps/test/WEB-INF/{classes, lib}

[[Email protected] Tomcat] # Vim/usr/local/tomcat/webapps/test/index. jsp

<% @ Page Language = "Java" %>

<HTML>

<Head> <title> tomcatb </title>

<Body>

<H1> <font color = "red"> tomcatb.magedu.com </font>

<Table align = "center" border = "1">

<Tr>

<TD> session ID </TD>

<% Session. setattribute ("magedu.com", "magedu.com"); %>

<TD> <% = session. GETID () %> </TD>

</Tr>

<Tr>

<TD> created on </TD>

<TD> <% = session. getcreationtime () %> </TD>

</Tr>

</Table>

</Body>

</Html>

Install httpd and configure reverse generation

[[Email protected] ~] # Yum-y install httpd













This article from the "broken knife" blog, please be sure to keep this source http://90sec.blog.51cto.com/7404127/1559203

Build a High-Performance cluster with Apache + Tomcat + session + memcache

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.