Apache + Tomcat load balancing cluster

http://weijie.blog.51cto.com/340746/68195

APACHE 2.2.8 + TOMCAT6.0.14 configure load balancing

Objectives:

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: / / 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

</ 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">

To

<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: / / 127.0.0.1:8009 loadfactor = 1 route = jvm1

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

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

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

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

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

BalancerMember ajp: / / 127.0.0.1:9003 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 = "228.0.0.4"

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:// 127.0.0.1 to access, there will be familiar cats.

And then were visited by

http:// 127.0.0.1:8080, http:// 127.0.0.1:9080, http:// 127.0.0.1:8081, http:// 127.0.0.1:9002 they access content and above http:// 127.0.0.1 is the same.

This shows the successful integration of apache and TOMCAT!

2, EQ tests

Many visits by http:// 127.0.0.1, 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.

分类:Web 时间:2010-05-04 人气:408
分享到:
blog comments powered by Disqus

相关文章

  • spring xml configuration file to load the way 2010-07-03

    spring xml configuration file to load the way, if there were three kinds, xml is the most common spring applications configure the source. Spring in support of several container assembly using the xml bean, including: XmlBeanFactory, ClassPathXmlAppl

  • apache htpasswd command Detailed description 2010-09-11

    Original Source: http://www.leapsoul.cn/?p=472 An article describes how to use Apache to achieve a ban on Directory Access (Prohibition tour directory or file listed in the list) to prohibit or allow access to IP and domain name directories. Actually

  • Apache + JK + Tomcat load balancing configuration 2011-01-07

    Online on the Apache + JK + Tomcat cluster configuration examples are many, according to an example configuration down, basic to run, but in some important areas are not further instructions. The company is using a product Apache + JK + Tomcat cluste

  • Apache + JK Tomcat load balancing cluster 2010-11-24

    Cluster is different from the distributed solution, which is used in each server running the same strategy applied by the streaming server is responsible for balance, which complicated the whole system to improve capacity and throughput is a more eff

  • Nginx IP and port-based load balancing 2011-05-14

    www.greatwqs.com and blog.greatwqs.com domain name servers are pointing to where Nginx IP. User access http://www.greatwqs.com , load balancing to 192.168.1.2:80,192.168.1.3:80,192.168.1.4:80,192.168.1.5:80 its four servers. User access http://blog.g

  • You should be aware of load balancing technology 2010-06-20

    This Guidance: In this paper, load balancing technology a more detailed description of all the text in the description by the network load balancing can understand the working principle and its role. Says situation is changing every minute in the net

  • Apache + Tomcat load balancing. Cluster configuration 2010-03-19

    This article is read by several predecessors on Apache + Tomcat load balancing, clustering related articles put together in order to access an article. For instructions are load balancing, clustering, and their advantages are discussed here will not

  • Based on mod_proxy + Apache 2.2.16 + Tomcat 7 load balancing and clustering configuration (switch) 2011-09-25

    Transfer http://www.iteye.com/topic/757125 Chapter I. Background For most enterprise applications, and hope to be 7 * 24-hour operation. To maintain such a high availability and easy, the more common practice is to deploy the system on multiple machi

  • Apache + tomcat load balancing configuration entry 2010-09-15

    This document is a preliminary document the configuration of load balancing, performance optimization does not involve too many things. So much also made a direct cut to the chase. First, preparatory work Install and configure the JDK environment var

  • apache + Tomcat load balancing, and the realization of Session Binding 2010-03-24

    [Change] http://www.cnblogs.com/zhangyi85/archive/2009/04/15/1436786.html Cluster Background 1.1 Definition of Terms Services software is b / s, or c / s structure, s part of the b or c for the provision of services of software systems. Services, har

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.618 (s). 12 q(s)