Originally intended only to write Tomcat cluster deployment, simplify the Apache and Tomcat integration process. Later thought, this does not facilitate the use of Apache friends to learn the contents of this article. So simply increase the length, so that the Apache does not understand the friend can have a preliminary understanding of Apache, Apache.
If you do not understand the concept of clustering, you can look at one of the previous writing: WebLogic Deployment cluster and proxy Server This article is a detailed explanation of the concept of the cluster, and unlike the WebLogic cluster, the deployment of the application on each sub-server is done automatically by the WebLogic container. and Tomcat needs to copy the project manually.
One, load balanced network topology diagram.
One, Apache server installation and configuration.
1. First download the Apache Server installation version, double-click the installation, the next step directly next do not need to do any configuration.
2. Install and open the installation directory and locate the Conf directory.
1. Manual creation of two files
1234567891011121314151617181920 |
mod_jk.conf
#================从这里复制================
#加载mod_jk Module 注意文件名根据实际情况而填
LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so
#指定 workers.properties文件路径
JkWorkersFile conf/workers.properties
#指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器
JkMount /*.
do
controller
JkMount /*WEB-INF controller
JkMount /*j_spring_security_check controller
JkMount /*.action controller
JkMount /servlet/* controller
JkMount /*.jsp controller
JkMount /*.
do
controller
JkMount /*.action controller
JkMount /* controller
#================文件内容================
|
+ View Code
2. Modify the contents of the httpd.conf file
Open the httpd.conf file with the last line plus: Include conf/mod_jk.conf
Apache default port is 80, if you need to change the port directly to find the file under the Listen 80 field, the 80 to get rid of it.
3. Add Mod_jk-1.2.31-httpd-2.2.3.so Plugin
Download the mod_jk-1.2.31-httpd-2.2.3.so file and add it to the Modules folder. This so file is a plugin that must be used to configure load balancing.
With this, Apache doesn't have to move.
Third, the installation and configuration of Tomcat server.
1. Download Tomcat directly after the extraction.
2. Open the Server.xml file under the Conf folder to modify the following to ensure that the corresponding ports of the two Tomcat do not conflict:
First place: Port
<server port= "9011" shutdown= "Shutdown" >
The second place: port, Redirectport Note that the encoding format needs to be set to GBK, otherwise there is garbled problem
<connector port= "9001" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "9441"
uriencoding= "GBK"/>
Third place: Port corresponds to port, Redirectport configured in Apache configuration file, note encoding
<connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/>
Replace with:
+ View Code
Section four: Jvmroute the Tomcat name that is configured in the Apache configuration file
<engine name= "Catalina" defaulthost= "localhost" jvmroute= "TOMCAT1" >
Place five: Only the blue flag is changed to port
In <engine name= "Catalina" defaulthost= "localhost" jvmroute= "TOMCAT1" > Add the following fields below:
1234567891011121314151617181920212223242526272829 |
<
Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<
Manager
className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="6"/>
<
Channel
className="org.apache.catalina.tribes.group.GroupChannel">
<
Membership
className="org.apache.catalina.tribes.membership.McastService"
bind="127.0.0.1"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<
Receiver
className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4001"
selectorTimeout="100"
maxThreads="6"/>
<
Sender
className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<
Transport
className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" timeout="60000"/>
</
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;"/>
<
ClusterListener
className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</
Cluster
>
|
Iv. Application Deployment and operation
1. Copy the project to the WebApps folder under all Tomcat.
2. Locate the Startup.bat file in the Tomcat Server bin directory and double-click Start Tomcat
3. Start Apache after all Tomcat is started: directly click on the icon to start
V. Copy of Session
Open the Web. xml file under the Web-inf folder in the project, and add <distributable/> to the penultimate line
Five, test page
Create the following files to be placed in the project for testing load balancing and session replication
File name: test.jsp
1 <%@ page contenttype= "text/html; CHARSET=GBK "%> 2 <%@ page import=" java.util.* "%> 3 This is the APACHE+TOMCAT deployment load balancer (or cluster), and if there is a need to deploy multiple sets of clusters on the same computer, there will be some changes in the configuration
Apache+tomcat Deploying load balancing (or clustering)