Apache + Tomcat load balancing cluster


APACHE 2.2.8 + TOMCAT6.0.14 configure load balancing


Apache and tomcat configuration using an application of the web site, to meet the following requirements:

1, Apache as HttpServer, followed connect multiple tomcat application examples, and for load balancing.

2, set the Session timeout for the system, including the Apache and tomcat

3, shielding the list of files for the system, including the Apache and tomcat

Note: This routine to a machine as an example, that the same machine and 4 upload an apache Tomcat.

First, preparatory work: the procedure for installation (if installed JDK1.5 or above to ensure the version)

APAHCE 2.2.8 Download: apache_2.2.8-win32-x86-no_ssl.msi

TOMCAT6.0.14 Download: apache-tomcat-6.0.14.zip direct decompression.

Second, the installation process

APAHCE installation directory: D: \ Apache.

4 TOMCAT directory: self-extract (D: \ Tomcat Cluster Server \) next. Were tomcat6.0, tomcat6.01, tomcat6.02, tomcat6.03

These detailed description of the installation process is not.

Third, configure

1, Apache Configuration

1.1, httpd.conf configuration

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

Module removed the following notes, where there is no use for apache and tomcat mod_jk.so link itself from the apache 2.X after the function has been integrated mod_jk.so. Just a simple note to remove the following lines, before the equivalent of more complicated with mod_jk.so configured. Here the main method of using a proxy, it's that 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

To find <IfModule dir_module> </ IfModule> modified to add index.jsp

<IfModule Dir_module>

DirectoryIndex index.html index.jsp

</ IfModule>

1.1.1, at the bottom to join

ProxyRequests Off

<proxy balancer://cluster>

BalancerMember ajp: / / loadfactor = 1 route = jvm1

BalancerMember ajp: / / loadfactor = 1 route = jvm2

BalancerMember ajp: / / loadfactor = 1 route = jvm3

BalancerMember ajp: / / loadfactor = 1 route = jvm4

</ Proxy>

Members of the above four BalancerMember tomcat cluster is configured. Will be described later.

1.2, httpd-vhosts.conf set

Next, set up a virtual host. APACHE virtual host settings are as follows:

First of all, to modify the conf / httpd.conf find (# Include conf / extra / httpd-vhosts.conf)

Remove the comments.

# Virtual hosts

Include conf / extra / httpd-vhosts.conf

In the paper (extra / httpd-vhosts.conf) at the bottom to join

<VirtualHost *:80>

ServerAdmin weijie@126.com

ServerName localhost

ServerAlias localhost

ProxyPass / balancer: / / cluster / stickysession = jsessionid nofailover = On

ProxyPassReverse / balancer: / / cluster /

</ VirtualHost>

One of the domain and path settings according to your own situation

And then set the virtual host TOMCAT

2 configuration tomcat

2.1. Configuration server shutdown

We need a machine to run four different tomcat, tomcat need to modify the closure of a different mouth, to avoid the situation of the port is occupied. One tomcat6.0 with default values, not modify. The other three changes. In tomcat6.01 \ conf, tomcat6.02 \ conf under and tomcat6.03 \ conf server.xml found under the server, will:

<Server Port="8005" shutdown="SHUTDOWN">


<Server Port="XXXX" shutdown="SHUTDOWN">

XXXX here that a different port: My other three were used tomcat 9005,8006, 9007

2.2. Configuration Engine

To comment out the original configuration, to remove a comment below. And marked jvmRoute = "jvm2".

<Engine Name="Standalone" defaultHost="localhost" jvmRoute="jvm2">

The following is the original configuration.

<! - <Engine Name="Catalina" defaultHost="localhost"> ->

Other (tomcat6.02 and tomcat6.03) have the same configuration. Note: jvmRoute configured not the same.

<Engine Name="Standalone" defaultHost="localhost" jvmRoute="jvm3">

<Engine Name="Standalone" defaultHost="localhost" jvmRoute="jvm4">

2.3. Configuration Connector

The original default configuration.

<! - Define an AJP 1.3 Connector on port 8009 ->

<Connector Port="8009" protocol="AJP/1.3" redirectPort="8443" />

Here is the key link apache and tomcat, apache front is through AJP protocol to communicate with tomcat, and to complete the load balancing effect. Can also use the HTTP protocol. Attention to how they are connected communication, above the red part of the (port = "8009") is the connection interface of the.

The other three tomcat's <Connector port="XXX" /> port were replaced with the above

<proxy balancer://cluster>

# Corresponds with tomcat6.0, route and <Engine jvmRoute="jvm1"> correspond.

BalancerMember ajp: / / loadfactor = 1 route = jvm1

# And tomcat6.01 correspond, route and <Engine jvmRoute="jvm2"> correspond.

BalancerMember ajp: / / loadfactor = 1 route = jvm2

# And tomcat6.02 correspond, route and <Engine jvmRoute="jvm3"> correspond.

BalancerMember ajp: / / loadfactor = 1 route = jvm3

# And tomcat6.03 correspond, route and <Engine jvmRoute="jvm4"> correspond.

BalancerMember ajp: / / loadfactor = 1 route = jvm4

</ Proxy>

The port corresponding, tomcat6.01 the ajp port port: 9009. Tomcat6.02 the ajp port port: 9001. tomcat6.03 the ajp port port: 9003. a certain line with the above. The value should also change redirectPort only to ensure that the four tomcat's not the same.

2.5. Configuration Cluster (to be revised in each tomcat)

The original configuration.

<Cluster ClassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

Modify the following code: <Receiver port="XX"/> port must ensure uniqueness.

<Cluster ClassName="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">

<Manager className = "org.apache.catalina.ha.session.BackupManager"

expireSessionsOnShutdown = "false"

notifyListenersOnReplication = "true"

mapSendOptions = "6" />

<! -

<Manager className = "org.apache.catalina.ha.session.DeltaManager"

expireSessionsOnShutdown = "false"

notifyListenersOnReplication = "true" />


<Channel ClassName="org.apache.catalina.tribes.group.GroupChannel">

<Membership className = "org.apache.catalina.tribes.membership.McastService"

address = ""

port = "45564"

frequency = "500"

dropTime = "3000" />

<Receiver className = "org.apache.catalina.tribes.transport.nio.NioReceiver"

address = "auto"

port = "5001"

selectorTimeout = "100"

maxThreads = "6" />

<Sender ClassName="org.apache.catalina.tribes.transport.ReplicationTransmitter">

<Transport ClassName="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

</ Sender>

<Interceptor ClassName="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

<Interceptor ClassName="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>

<Interceptor ClassName="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>

</ Channel>

<Valve className = "org.apache.catalina.ha.tcp.ReplicationValve"

filter = ".* \. gif; .* \. js; .* \. jpg; .* \. png; .* \. htm; .* \. html; .* \. css; .* \. txt ; "/>

<Deployer className = "org.apache.catalina.ha.deploy.FarmWarDeployer"

tempDir = "/ tmp / war-temp /"

deployDir = "/ tmp / war-deploy /"

watchDir = "/ tmp / war-listen /"

watchEnabled = "false" />

<ClusterListener ClassName="org.apache.catalina.ha.session.ClusterSessionListener"/>

</ Cluster>

This setting is mainly used for tomcat cluster.

Fourth, start the service, test the example tomcat comes

1, test apache and tomcat collaboration.

First in each tomcat \ webapps \ ROOT index.jsp under the following test code section with the following: (X represents a different tomcat output different information), to remove index.html, so as not to affect the test results. Add in the final surface. That is </ table> </ body> between.


System.out.println ("tomcat6.0X deal with request");


And then look through http:// to access, there will be familiar cats.

And then were visited by

http://, http://, http://, http:// they access content and above http:// is the same.

This shows the successful integration of apache and TOMCAT!

2, EQ tests

Many visits by http://, to see the real effect, we must use some pressure testing tool for Microsoft Microsoft Web Application Stress Tool for simple stress test, or you rely on constant refresh is not shown You only have a tomcat's console output. Pressure testing tools only simulate large numbers of users simultaneously access, you will find four have played tomcat console control information on the equalizer working.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Apache + Tomcat load balancing cluster

  • Answer: After 2.2 upgrade mysql question-driven

    windows installed after the mysql gem error, error is approximately: ArgumentError (NULL pointer given): (eval): 3: in `each_hash ' (eval): 3: in `all_hashes' This is feeling under the windows of the question if the mysql gem version libmysql ...

  • Struts2 Spring Hibernate integration of easy

    1. Add Spring 2.0 in Libraries Choose the following four jar, and configure the / WEB-INF/lib under Spring2.0 AOP Libraries Spring2.0 Core Libraries Spring2.0 Persistence Core Libraries Spring2.0 WEb Libraries At the same time, the applicationContext ...

  • js page Jump implementation of a number of ways

    The first is: <script language="javascript" type="text/javascript"> window.location.href = "login.jsp? backurl =" + window.location.href; </ script> The second: <script language="javascript"> alert

  • Struts2 Spring Hibernate's easy to integrate

    1. Add Spring 2.0 in Libraries Choose the following four jar, and configure the / WEB-INF/lib under Spring2.0 AOP Libraries Spring2.0 Core Libraries Spring2.0 Persistence Core Libraries Spring2.0 WEb Libraries At the same time, the applicationContext ...

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • RoR explained

    ROR is Ruby on Rails. Ruby is a well-known has been very good dynamic language It's dynamic language. Simple and easy. Dynamic languages are interpreted, but the performance may make a discount, but not absolute, because the application is complex, th

  • java read file

    java read documents in two ways: java.io and java.lang.ClassLoader When using the java.io, when java.lang.ClassLoader use it? (Note: If prior to read xml file java read file clearly aware of these two methods have been like! Can take much less to understa

  • Some interview questions java

    The first is the company give you a chance to meet, it is necessary to know to meet from time to equal the interview, and have a lot of companies to see you at the first time will give you a ready point of doing something trivial, these questions, althoug

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • What is the appfuse

    First, Appfuse brief introduction Matt Raible are Appfuse developed a guiding entry-level J2EE framework, how to integrate its popular Spring, Hibernate, ibatis, struts, Xdcolet, junit, etc. give the basic framework of the model, the latest version 1.7 is

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries