Confluence Docs 3.3 : Apache and Tomcat load balancing
This page last changed on Aug 26, 2007 by pfragemann.
OverviewThe following is a description of how to setup a Confluence Cluster on a Windows machine using Apache and mod_jk to handle the loadbalancing. The characteristics of this cluster are:
What do you need?
Apache configurationEdit the main Apache config file, conf/http.conf:
Create a workers.properties file in the Apache conf/ directory. This version of the workers.properties file is configured to use 2 Tomcat instances: tomcat1 and tomcat2. worker.list=loadbalancer worker.tomcat1.port=18081 worker.tomcat1.host=localhost worker.tomcat1.type=ajp13 worker.tomcat1.lbfactor=1 worker.tomcat2.port=28081 worker.tomcat2.host=localhost worker.tomcat2.type=ajp13 worker.tomcat2.lbfactor=1 worker.loadbalancer.type=lb worker.loadbalancer.balanced_workers=tomcat1, tomcat2 worker.loadbalancer.method=Busyness Tomcat configurationThe Tomcat configuration below will run multiple instances from the same binaries in the main Tomcat directory. For complete documentation of this configuration, see the RUNNING.txt file in the Tomcat distribution. Create instance home directoriesCreate a directory for each instance of Tomcat, somewhere outside where you installed Tomcat. For example, if you extracted Tomcat to /opt/apache/tomcat-5.5, your instances could be in /var/tomcat-instances/tomcat1, /var/tomcat-instances/tomcat2. These folders will be referred to as the instance home directories. Copy the following folders from the Tomcat installation directory into each instance home directory. Some of the folders may be empty, but copy them anyway.
Configure server.xml in each instanceEdit conf/server.xml in the instance home directories to include the Confluence application and have distinct listen ports for Server, HTTP Connector and AJP13 Connector. All nodes can use the same Confluence webapp as long as you set confluence.home via a system property (see startup scripts below). Attached are two sample configurations:
To use these sample config files, you will need to edit them to set the Confluence web-app location and the data source configuration. If editing the configuration files yourself, the points to note are:
Create a startup script for each instanceThe startup scripts for each instance must set the CATALINA_BASE environment variable and confluence.home system property. The variables in the sample scripts below should reference:
tomcat1/startup.bat:
set CATALINA_HOME=C:\home\mryall\opt\apache\apache-tomcat-5.5.16
set CATALINA_BASE=C:\home\mryall\var\tomcat-instances\tomcat1
set JRE_HOME=C:\Java\jre1.5.0_06
set JAVA_OPTS=-Dconfluence.home=C:\home\mryall\data\confluence\cluster\tomcat1 -Xmx512m
%CATALINA_HOME%\bin\startup.bat
tomcat2/startup.bat:
set CATALINA_HOME=C:\home\mryall\opt\apache\apache-tomcat-5.5.16
set CATALINA_BASE=C:\home\mryall\var\tomcat-instances\tomcat2
set JRE_HOME=C:\Java\jre1.5.0_06
set JAVA_OPTS=-Dconfluence.home=C:\home\mryall\data\confluence\cluster\tomcat2 -Xmx512m
%CATALINA_HOME%\bin\startup.bat
Continue setting up ConfluenceFollow the Confluence Cluster Installation procedure with the steps following the app server setup. TroubleshootingGeneral advice The above tomcat configurations enable HTTP connectors on each Tomcat instance so that you can connect to the nodes individually. To check whether the load balancer (Apache & mod_jk) is causing the problem, try connecting to the individual Tomcat instances. Please note that you should not allow users to directly access individual nodes in production mode: You don't want people to bookmark nodes since the node details might change, or single nodes may be taken out of the cluster for maintenance while the cluster itself is still available. Session-affinity doesn't seem to be working? Ensure the name you use for your worker in workers.properties (e.g. tomcat1) matches the jvmRoute attribute of the engine tag in your Tomcat server.xml. For an example, search for 'Engine' in the attached sample config. For troubleshooting your Confluence cluster, see Cluster Troubleshooting. ReferencesGeneralhttp://raibledesigns.com/tomcat/ http://httpd.apache.org/ Tomcat Clustering supporthttp://tomcat.apache.org/tomcat-5.0-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-5.0-doc/balancer-howto.html
http://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html |
![]() |
Document generated by Confluence on Jul 09, 2010 01:09 |