Tomcat + HTTP reverse proxy + memcached session persistence

Source: Internet
Author: User
Tags jcenter java se

The Tomcat server is a free open-source Web application server, which is a lightweight application server. It is widely used in small and medium systems and concurrent users, is the first choice for developing and debugging JSP programs. For a beginner, it can be thought that when an Apache server is configured on a machine, it can be used to respond to HTML (an application under the standard General Markup Language .) Page access request. In fact, Tomcat is an extension of the Apache server, but it runs independently. Therefore, when you run tomcat, it actually runs independently as a process independent of Apache.

The trick is that when the configuration is correct, Apache serves the HTML page, while Tomcat actually runs the JSP page and servlet. In addition, like Web servers such as Tomcat and IIS, Tomcat can process HTML pages. In addition, it is a Servlet and JSP Container, and an independent servlet container is the default mode of Tomcat. However, Tomcat cannot process static html as well as Apache servers. The latest version of Tomcat is 8.0.0-RC1 (alpha) released.

Tomcat is very popular with programmers, because it occupies a small amount of system resources during running and has good scalability. It supports common functions of development application systems such as load balancing and mail service; in addition, it is constantly being improved and improved. Any interested programmer can change it or add new functions to it.

Ii. Deployment of JDK in the Java environment

2.1 Java Introduction

Java components mainly include four independent but related technologies:

Java programming language design, Java API, Java class, JVM. Among them, JVM is a Java Virtual Machine. Different systems use JVM to parse and run Java programs. In this way, Java's philosophical principle is realized: one compilation and running everywhere!

JVM implementation method:

The interpreter interprets the byte and executes it. The interpreter parses the byte in one sentence;

The instant compiler caches the interpreted data and requires more memory to cache the interpreted results;

Adaptive Compiler: caches 20% of the code and increases the speed by about 80%. This follows the "rule "!

JVM types:

Sun's hotspot JVM, including JRE and JDK, implements only the Java Runtime Environment, while JDK contains the Java development environment and runtime environment;

Open-source openjdk: similar to JDK, it is also a combination of development and runtime environments.

Java can be divided into two types based on different application fields.
Java SE: Standard Edition, formerly j2se
Java EE: Enterprise Edition, J2EE
Jave me: mobile edition

2.2 install and configure JDK in the Java environment

The installation of the Java environment allows you to install rpm, common binary, and Source Code compiling methods. Here, yum is used to install

# Yum-y install java-1.6.0-openjdk *

Iii. Experiment Process

1. Experiment Topology

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" capture "border =" 0 "alt =" capture "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867761mxen.png "width =" 544 "Height =" 196 "/>

2. experiment environment

Apache 192.168.1.135

Tomcata 192.168.1.133

Tomcatb 192.168.1.134

Memcached 192.168.1.135)

Memcached related packages

Javolution-5.4.3.1.jar

Memcached-2.4.2.jar

Memcached-session-manager-1.3.0.jar

Msm-javolution-serializer-cglib-1.3.0.jar

Msm-javolution-serializer-jodatime-1.3.0.jar

In the attachment


Install Tomcat

Yum-y install Tomcat 6 tomcat6-webapps tomcat6-admin-webapps

Tomcat6-docs-webapp tomcat6-javadoc

Tomcat6 configuration file:/etc/tomcat6

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" 2323 "border =" 0 "alt =" 2323 "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867761HADO.png "width =" 483 "Height =" 93 "/>

The main configuration file is server. xml.

All content under/usr/share/tomcat6/

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" 231321 "border =" 0 "alt =" 231321 "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867761zoOa.png "width =" 325 "Height =" 44 "/>

Install javacenter2.0.

First modify server. xml

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" 22131231231 "border =" 0 "alt =" 22131231231 "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867761kmRY.png "width =" 424 "Height =" 131 "/>

Create the jcenter directory under webapps, decompress all content under the javacenter installation package, and modify

Config. properties file with 777 permission

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" capture "border =" 0 "alt =" capture "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867762su8w.png "width =" 508 "Height =" 138 "/>

Authorize jcenter in local database and create relevant database

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" authorize jcenter Database "border =" 0 "alt =" authorize jcenter Database "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867762XgNQ.png "width =" 502 "Height =" 109 "/>

Start Installation

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" Install jcenter "border =" 0 "alt =" Install jcenter "src =" http://img1.51cto.com/attachment/201409/28/8914310_14118677626iFz.png "width =" 523 "Height =" 148 "/>

Result

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" jcenter installed "border =" 0 "alt =" jcenter installed "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867762RL4l.png "width =" 488 "Height =" 190 "/>

Create the test directory under webapps and write down the test homepage.

Index. jsp

Verify

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" 112 "border =" 0 "alt =" 112 "src =" http://img1.51cto.com/attachment/201409/28/8914310_141186776395Gd.png "width =" 244 "Height =" 98 "/>

Write the same test file in tomcatb.

2. on the Apache server

Reverse Proxy experiment of httpd

View the current version of the httpd Module

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" capture "border =" 0 "alt =" capture "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867763euiI.png "width =" 265 "Height =" 134 "/>

Add the following virtual host to the HTTP configuration file:

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867763SCYc.png "width =" 408 "Height =" 111 "/>

Note that the local hosts file can be parsed and IP addresses are used if the local hosts file fails to be parsed.

Verify

 

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867763EScw.png "width =" 244 "Height =" 120 "/>

3. Apache Server Load balancer cluster + memcached maintain session

Apache cluster configuration file

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867763wqXU.png "width =" 421 "Height =" 151 "/>

Then, enable the memcached server and modify the configuration file of Tomcat's context. xml. For details, see

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867764rBNx.png "width =" 511 "Height =" 144 "/>

Verify

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867764Fz1g.png "width =" 244 "Height =" 100 "/>

650) This. width = 650; "style =" border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/28/8914310_1411867764MAQH.png "width =" 244 "Height =" 109 "/>

Tomcat + HTTP reverse proxy + memcached session persistence

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.