System environment: Windows XP SP3, jdk1.6.0 _ 13 software version: httpd-2.2.21-win32-x86-openssl-0.9.8r.msiapache-tomcat-6.0.33tomcat-connectors-1.2.32-windows-i386-httpd-2.2.x I was on a machine for testing, because I
System environment: Windows XP SP3, jdk1.6.0 _ 13
Software version: httpd-2.2.21-win32-x86-openssl-0.9.8r.msi apache-tomcat-6.0.33 tomcat-connectors-1.2.32-windows-i386-
Httpd-2.2.x
I did a test on a machine, because I have completed apache server load balancer and replica of Tomcat 6 clusters and sessions,
You may need to modify the configuration as follows:
1. modify httpd. conf of apache:
First, load the required so file and remove the comments before the following lines.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
Add the load connector configuration
LoadModule jk_module modules/mod_jk.so
JkWorkersFile "conf \ workers. properties"
JkMount/*. jsp controller
Remove comments from VM
Include conf/extra/httpd-vhosts.conf
Add server load balancer configuration at the end
SetHandler server-status
Order Deny, Allow
Deny from all
Allow from all
SetHandler balancer-manager
Order Deny, Allow
Deny from all
Allow from all
ProxyRequests Off
ProxyPass/test balancer: // tomcatcluster/stickysession = jsessionid nofailover = On
BalancerMember ajp: // 127.0.0.1: 8009 loadfactor = 1 route = route 1
BalancerMember ajp: // 127.0.0.1: 9009 loadfactor = 1 route = tomcat2
2. add the following to the apache httpd-vhosts.conf file:
ServerAdmin webmaster@163.com
ServerName localhost
ServerAlias localhost
ProxyPass/balancer: // tomcatcluster/stickysession = jsessionid nofailover = On
ProxyPassReverse/balancer: // tomcatcluster/
3. create the workers. properties file
#========= Export AT1 ========
Worker. tomcat1.port = 8009 # ajp13 port number, which is configured in server. xml under tomcat. the default value is 8009.
Worker. tomcat1.host = localhost # tomcat host address. if not, enter the IP address
Worker. tomcat1.type = ajp13
Worker. tomcat1.lbfactor = 1 # server weighting ratio. the higher the value, the more requests are allocated.
#======= Tomcat2 =========
Worker. tomcat2.port = 9009 # ajp13 port number, which is configured in server. xml under tomcat,
Worker. tomcat2.host = localhost # tomcat host address. if not, enter the IP address
Worker. tomcat2.type = ajp13
Worker. tomcat2.lbfactor = 1 # server weighting ratio. the higher the value, the more requests are allocated.
#======= Controller, server load balancer controller ========
Worker. controller. type = lb
Worker. controller. balanced_workers = worker AT1, tomcat2 # specify tomcat that shares the request
Worker. controller. sticky_session = false # worker. controller. sticky_session = 1
4. modify tomcat server. xml:
In addition to changing both tomcat conflicting ports, you also need to add the cluster settings.
-- The other is Tomcat 2.
ExpireSessionsOnShutdown = "false"
NotifyListenersOnReplication = "true"/>
Address = "228.0.0.4"
Port = "45564"
Frequency = "500"
DropTime = "3000" type = "codeph" text = "codeph"/>
Address = "auto"
Port = "5001"
SelectorTimeout = "100"
MaxThreads = "6"/>
Filter = ". *\. gif ;. *\. js ;. *\. jpg ;. *\. png ;. *\. htm ;. *\. html ;. *\. css ;. *\. txt; "/>
TempDir = "/tmp/war-temp /"
DeployDir = "/tmp/war-deploy /"
WatchDir = "/tmp/war-listen /"
WatchEnabled = "false"/>
5. configure web. xml in the webapps
You must add
This application will copy the Session with the cluster server
After the configuration is complete, start all tomcat servers and then start the apache2.2 server.
6. the following jsp can be deployed as a test program in tomcat1, tomcat2
<% @ Page contentType = "text/html; charset = GBK" %>
<% @ Page import = "java. util. *" %>
Cluster App Test
Server Info:
<%
Out. println (request. getLocalAddr () + ":" + request. getLocalPort () +"
"); %>
<%
Out. println ("
ID "+ session. getId () +"
");
String dataName = request. getParameter ("dataName ");
If (dataName! = Null & dataName. length ()> 0 ){
String dataValue = request. getParameter ("dataValue ");
Session. setAttribute (dataName, dataValue );
}
Out. print ("Session List");
Enumeration e = session. getAttributeNames ();
While (e. hasMoreElements ()){
String name = (String) e. nextElement ();
String value = session. getAttribute (name). toString ();
Out. println (name + "=" + value +"
");
System. out. println (name + "=" + value );
}
%>
After successful configuration, the result is 2017at1. the session content is the same in the background of Tomcat 2 and is distributed through apache access requests.
From my complaint