APACHE 2.2.15+tomcat6.0.26 Configuring Load Balancing

Source: Internet
Author: User

Goal:

Use Apache and Tomcat to configure a Web site that can be applied, to meet the following requirements:

1, Apache as Httpserver, behind the connection of multiple Tomcat application instances, and load balancing.

2. Set the Session timeout for the system, including Apache and Tomcat

3, for the System screen file list, including Apache and Tomcat

Note: This example takes one machine (operating system Windows 2008) as an example, that is, one Apache and 4 Tomcat are installed on the same machine.

First, download the software

Httpd-2.2.15-win32-x86-no_ssl

Jdk-6u18-windows-i586.exe

Apache-tomcat-6.0.26-windows-x86.zip

Second, the installation program

1. JDK installed by default, set JA V a_home in environment variable

(The default JDK directory is C:\Program files\java\jdk1.6.0_18)

A, go to the Windows desktop, right-select "My Computer"--"Properties"

B, select "Advanced" tab, click "Environment Variables"

C, under "System variables" click New popup "New system variable", variable name input "JA V a_home", variable value entered "C:\Program files\java\jdk1.6.0_18" click OK.

2, APAHCE installation directory: D:\Apache.

3, four TOMCAT directories: Unzip yourself to (D:\Tomcat Cluster Server). tomcat6.0, tomcat6.01, tomcat6.02, tomcat6.03, respectively

Third, the configuration

1. Apache Configuration

1.1. httpd.conf Configuration

Modify the APACHE configuration file D:\Apache \conf\httpd.conf

Remove the comments from the following Module, which does not use mod_jk.so for Apache and Tomcat links, and since 2.X Apache itself has integrated the functionality of mod_jk.so. Simply remove the following lines of comments, equivalent to the previous use of mod_jk.so more cumbersome configuration. Here the main use of the agent method, it is so simple. LoadModule Proxy_module modules/mod_proxy.so

LoadModule Proxy_connect_module modules/mod_proxy_connect.so

LoadModule Proxy_ftp_module modules/mod_proxy_ftp.so

LoadModule Proxy_http_module modules/mod_proxy_http.so

LoadModule Proxy_ajp_module modules/mod_proxy_ajp.so

LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so

And then find the plus index.jsp modified into

DirectoryIndex index.html index.jsp

1.1.1, join at the bottom

Proxyrequests OFF

Balancermember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1

Balancermember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2

Balancermember ajp://127.0.0.1:9001 loadfactor=1 route=jvm3

Balancermember ajp://127.0.0.1:9003 loadfactor=1 route=jvm4

The four Balancermember members above are the Tomcat clusters that we configured. It will be explained later.

1.2. httpd-vhosts.conf setting

Next, make the virtual host settings. APACHE's virtual host settings are as follows:

First to modify conf/httpd.conf found (#Include conf/extra/httpd-vhosts.conf)

Remove the note.

Virtual hosts

Include conf/extra/httpd-vhosts.conf

At the bottom of the file (extra/httpd-vhosts.conf), add

ServerAdmin

ServerName localhost

Serveralias localhost

Proxypass/balancer://cluster/stickysession=jsessionid Nofailover=on

proxypassreverse/balancer://cluster/

Where the domain name and path are set according to your own situation

Then set up the TOMCAT virtual host

2 Configuring Tomcat

2.1. Configure the shutdown of the server

We need to run 4 different tomcat on a single machine and need to modify the different Tomcat's shut-off ports to avoid port occupancy. Where tomcat6.0 is not modified with the default value. Three other modifications. In

Tomcat6.01\conf, tomcat6.02\conf and tomcat6.03\conf under the server.xml found in the server, will:

Switch

XXXX here represents a different port: My other three Tomcat uses 9005, 8006, 9007 2.2 respectively. Configure Engine

Comment out the original configuration and remove the comment from the following sentence. and marked jvmroute= "JVM2".

The following is the original configuration.

Other (tomcat6.02 and tomcat6.03) should be configured as well. Note: The Jvmroute configuration is not the same.

2.3. Configure Connector

The original default configuration.

This is the key to Apache and Tomcat links, and the foreground Apache communicates with Tomcat through the AJP protocol to achieve load balancing. You can also use the HTTP protocol. Notice how they connect to the communication, and the red part above is the connected interface.

Change the port of the other three tomcat to the one above

#与 tomcat6.0 Correspondence, route and correspondence.

Balancermember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1

#与 tomcat6.01 Correspondence, route and correspondence.

Balancermember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2

APACHE 2.2.15+tomcat6.0.26 Configuring Load Balancing

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.