I've only done two tomcat clusters.
First, install Apache for load Balancing.
Second, the installation of Apache Tomcatconnector as a request for distribution.
Third, install Tomcat:
1, download the Linux under the Tomcat installation package:
2, download the installation package online: Click to open the link
can also go to my upload of resources to download, but now can only use points, I do not need points. Address: Click on the Open link.
3, two times to extract the downloaded apache-tomcat-6.0.33.tar.gz file to/usr/local/, and renamed to TOMCAT1 and TOMCAT2 respectively
4, modify the TOMCAT2 port:
4.1 Open TOMCAT2 under Conf/server.xml file
4.2 Modify the following content:
1 Change the listening port of Tomcat off from 8005 to 8105
namely the
<server port= "8005" shutdown= "Shutdown" >
To
<server port= "8105" shutdown= "Shutdown" >
2) Change the HTTP service port number from 8080 to 8180
Found it
<!--Define a non-ssl http/1.1 Connector onport 8080-->
<connector port= "8080"
Change the 8080 here to 8180.
3) Change the AJP port number from 8009 to 8109
Found it
<!--Define a AJP 1.3 Connector on port8009-->
<connector port= "8009"
Change the 8009 here to 8109.
4 The HTTP proxy port from 8082 to 8182 (this configuration by default is commented out, you can skip this step)
Found it
<connector port= "8082"
Change the 8082 here to 8182.
5. Open Tomcat Cluster
5.1 Open Tomcat under Server.xml file, add jvmroute attribute on <Engine/> node, attribute value to your Tomcat name, such as:
<engine name= "Catalina" defaulthost= "localhost" jvmroute= "tomcat01" >
5.2 At the end of the <Engine/> node, add the following content, which is the cluster configuration:
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster" channelsendoptions= "8" > <mana Ger classname= "Org.apache.catalina.ha.session.DeltaManager" expiresessionsonshutdown= "false" not
Ifylistenersonreplication= "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.tra
Nsport.nio.NioReceiver "address=" Auto "port=" 4000 "autobind=" "selectortimeout=" 5000 "
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 "/> </Channel> <valve C Lassname= "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.apache.catalina.ha.session.JvmRouteSessionIDBinderListener "/> <clusterlistener classname= "Org.apache.catalina.ha.session.ClusterSessionListener"/> </Cluster>
6. Configure Apache
Open the conf/httpd.conf file under the Apache installation directory and add the following on the last side of the file:
# Load MOD_JK module
LoadModule jk_module modules/mod_jk.so
# Specify JK log file.
Jklogfile/var/log/mod_jk.log
# Specify JK log level [Debug/error/info]
jkloglevel Info
# Specify Workers.properties, this file tell JK:
# How many nodes and where they are.
Jkworkersfile conf/workers.properties
# Specify which requests should handled by which node.
Jkmount/* Controller
7, configure MOD_JK, describe the cluster node.
Create a new Workers.properties file in the folder where the Apache httpd.conf files are located, and write the following in the file:
#所有节点列表, where controller is a logical node, responsible for load balancing control, #如果JkMount中的URL指定给了controller就表示这个请求会被自动散列到某个物理节点上.
#注意: The name of the Tomcat that is really responsible for processing the request (here is TOMCAT1,TOMCAT2) must be #文件中配置的jvmRout的属性值是一致的 in the conf/server.xml. Worker.list = controller,tomcat01,tomcat02 #========tomcat01======== worker.tomcat01.port=8009 #ajp13 port number, in T Omcat under Server.xml configuration, default 8009 worker.tomcat01.host=localhost #tomcat的主机地址, if not for this machine, please fill in the IP address worker.tomcat01.type=ajp13 wor Ker.tomcat01.lbfactor = 1 #server的加权比重, the higher the value, the more requests #========tomcat02======== worker.tomcat02.port=8109 #ajp13 Port number, under Tomcat server.xml configuration, default 8009 worker.tomcat02.host=localhost #tomcat的主机地址, if not the native, please fill in the IP address worker.tomcat02.type= Ajp13 worker.tomcat02.lbfactor = 1 #server的加权比重, the higher the value, the more requests #========controller, the load-balancing controller ======== Worker.control
LER.TYPE=LB worker.controller.balance_workers=tomcat01,tomcat02 #指定分担请求的tomcat, balanced_workers in the older version, is no longer recommended for use. Worker.controller.sticky_session=1 #sticky_session为1表示, after the #当某一 client session is created, the following client initiates the requestAsk, that is, all requests for this session are always #负责处理 the node that first processed the request (unless the node is dead)
So far, the cluster is completed.
Iv. preparations for the cluster by the application
1.:<distributable/> elements need to be added to the web.xml of the application
2. Data stored in the session (e.g. attribute) must be serialized.
Reference blog 01:linux to build the Tomcat cluster
Reference Blog 02:tomcat cluster configuration