Operating system: Debian6.0 (192.168.225.129 virtual machine 1 units)
Software version: Apache-2.2.16, Tomcat-6.0.35
1. Installation software
>apt-get Install update
* Install Apache
>apt-get Install apache2
* Install Tomcat
>wget http://apache.etoak.com/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz
>tar zxvf apache-tomcat-6.0.35.tar.gz
>mv Apache-tomcat-6.0.35/user/local/tomcat
>cp/usr/local/tomcat/usr/local/tomcat2
* Install MOD_JK
>apt-get Install LIBAPACHE2-MOD-JK
2. Configure 2 Tomcat
Now that there are 2 tomcat directories in the/usr/local directory, you need to change the TOMCAT2 ports to prevent port conflicts.
>nano/usr/local/tomcat/conf/server.xml
There are 3 default ports that need to be changed:
1.<server port= "8004" shutdown= "shutdown" > I change to 8003
2.<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
Change to 7080
3.<connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/>
Change to 7009, where Redirectport 8443 does not need to be changed
O. Also need to add <Cluster> configuration in <Engine> configuration
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster" channelsendoptions= "8" >
<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= "Droptime=" "3000"/> <receiver Classname= "Org.apache.catalina.tribes.transport.nio.NioReceiver" address= "Auto" port= "4001" selectortimeout= "5 "Maxthreads=" 6 "/> <!--timeout=" 60000 "-- > <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= "" "/> <valve ClassnaMe= "Org.apache.catalina.ha.session.JvmRouteBinderValve"/> < 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.apac" He.catalina.ha.session.JvmRouteSessionIDBinderListener "/> <clusterlistener classname=" Org.apache.catalina.ha.session.ClusterSessionListener "/> </Cluster>
X. The last 2 Tomcat needs to change the <engine Jvmroute properties are TOMCAT1 and TOMCAT2, respectively, to correspond to the names in the worker.properties.
3. Configure Apache to be JK and tomcat cluster
After the installation of the Apache main directory for/etc/apache2, after the installation of MOD-JK, mods-enabled inside will be more than one jk.load
Create file/etc/apache2/mods-enabled/jk.conf
>nano/etc/apache2/mods-enabled/jk.conf
Jkworkersfile/etc/apache2/workers.properties
Jkshmfile/var/log/apache2/mod_jk.shm
Jklogfile/var/log/apache2/mod_jk.log
Jkloglevel Info
Create file/etc/apache2/workers.properties
>nano/etc/apache2/workers.properties
Worker.list=controller1
worker.tomcat1.port=8009
Worker.tomcat1.host=localhost
Worker.tomcat1.type=ajp13
Worker.tomcat1.lbfactor=1
worker.tomcat2.port=7009
Worker.tomcat2.host=localhost
Worker.tomcat2.type=ajp13
Worker.tomcat2.lbfactor=1
Worker.controller1.type=lb
Worker.controller1.sticky_session=1 #可选项0, 1
Worker.controller1.balance_workers=tomcat1,tomcat2
Change the/etc/apache2/sites-enabled/000-default file
Add before </VirtualHost>
Jkmount/* Controller1
(Controller1 corresponds to the name in Workers.properties)
After the configuration is complete, tomcat and Apache are started.
Test:
2 Tomcat deployments the same application: Home index.jsp display respective tomcat names TOMCAT1 and TOMCAT2
Through 80 port Access application, refresh several times, TOMCAT1 and tomcat2 rotate display.