...
See also HowToRedhat8JK2 for configuring Red Hat's Apache with a mod_jk2 binary and Tomcat 4.1
Quick
...
Start for Linux
This is just a quick start for people currently struggling with mod_jk2 and multiple hosts. It is a working configuration. My real content for this page will come in another week or so. But please feel free to collaborate on this page now!
Wiki Markup |
---|
This is working on Red Hat Linux. I use Unix Domain sockets because they eliminate the need to manage the list of IP ports. \[_One remaining task is to eliminate the need for the shutdown port. The shutdown command can be sent via AJP13, but the code from {{StopTomcat}} (in Tomcat v3.3) needs to be ported to use the connector classes._\] |
Layout
See the file in the Tomcat distribution called RUNNING.txt
for instructions on how to use CATALINA_BASE
and CATALINA_HOME
.
For each virtual host that will have its own JVM (shared JVM will be discussed later), setup a layout like:
...
This is just a basic description for this example. There are other options for placement of the site content.
Starting and Stopping Tomcat
Starting:
No Format |
---|
su --login ''user'' --command="export CATALINA_BASE=''path''; export JAVA_HOME=/usr/local/java; export JAVA_OPT=-server; /usr/local/tomcat-4/bin/startup.sh" |
...
I use a Sys{{`VI
`nit}} script that manages this cleanly for many sites. The user should be in the same group as the apache web server process.
Connector
No Format |
---|
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" } } } port="'''0'''" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="10" debug="0" connectionTimeout="0" useURIValidationHack="false" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/> |
Note that the port is set to zero. We're using UNIX domain sockets in this example, and we don't want the connector to open a port.
jk2.properties
...
No Format |
---|
handler.list=apr,channelUnix,request apr.NativeSo=/etc/httpd/modules/jkjni.so channelUnix.file=${jkHome}/work/jk2.socket |
conf/
...
worker.properties
...
No Format |
---|
["logger"] level=DEBUG [config:] file=${serverRoot}/conf/workers2.properties debug=0 debugEnv=0 [shm:] info=Scoreboard. Required for reconfiguration and status with multiprocess servers file=${serverRoot}/logs/jk2.shm size=1000000 debug=0 disabled=0 [workerEnv:] info=Global server options timing=1 debug=0 [channel.un:''workerName''] info=AF_UNIX socket connecting to "host" file=/''catalina_base''/work/jk2.socket debug=0 ''... repeat the above for each worker ...'' |
NOTE: You must make sure that the group owning the work/
directory is the same as the Group directive in httpd.conf
. Issue Run the following:
No Format |
---|
chgrp ''group'' work chmod g+s work |
If you have already tried tomcat Tomcat before doing this, then also issue: chgrp group execute the following:
No Format |
---|
chgrp group jk2.socket |
conf.d/jk2.conf
...
No Format |
---|
LoadModule jk2_module modules/mod_jk2.so |
httpd.conf
No Format |
---|
# This sends all resource requests to tomcat <VirtualHost ...> ServerName ''vhost'' DirectoryIndex index.jsp index.html JkSet uri:''vhost''/*.group ajp13:'' workerName '' # Alternative mapping mechanisms # 1. Place this in workers2.properties # [uri:''vhost''/] # group=ajp13:''workerName'' # # 2. This is the same as above, but in httpd.conf # JkSet uri:''vhost''/*.group ajp13:''workerName'' # # 3. This does the same thing, but with mapping inside httpd # NOTE: this is currently broken for virtual hosts #<Location "/*"> # JkUriSet group ajp13:''workerName'' #</Location> # # If you have a ServerAlias, methods #1 and #2 # require entries for each alias. </VirtualHost> # This sends only JSP page requests to tomcat <VirtualHost ...> ServerName ''vhost'' DocumentRoot /''catalina_base''/webapps/ROOT/ DirectoryIndex index.jsp index.html JkSet uri:''vhost''/*.jsp.group ajp13:''workerName'' </VirtualHost> |
...
This is only a start. But hopefully it will help people already trying to get this working, and having problems. For the Windows users, and others using TCP/IP ports or other transports, sorry. TCP/IP ports will be in the next revision, or you can glean the workers2.properties and jk2.properties directives from the official JK2 documentation.FYI
Configuring Apache 2.0.47 with Tomcat 4.1.27 and mod_jk 2.0.42
September 3rd 2003 - gturcios
During the last two weeks I was unable to find a good example for configuring Apache 2.0.47, Tomcat 4.1.27 and mod_jk-2.0.42. After piecing together examples and ideas from multiple sources I was able to get these three components to work in a load balanced environment. Each Apache and Tomcat lives on a separate server.
Current Environment
...
...
- 1
...
- WSD
...
- (Load
...
- Balancer)
...
- 3
...
- Apache
...
- servers
...
- (front-end)
...
- 3
...
- Tomcat
...
- servers
...
- (back-end)
...
The
...
- WSD
...
- DS
...
- Radware
...
- is
...
- set
...
- up
...
- with
...
- multiple
...
- farm
...
- addresses
...
- that
...
- point
...
- to
...
- the
...
- Apaches'
...
- primary
...
- and
...
- virtual
...
- interface
...
- IP
...
- addresses.
...
- Each
...
- Apache
...
- server
...
- is
...
- load
...
- balanced
...
- by
...
- the
...
- WSD
...
- using
...
- a
...
- weighted
...
- round-robin
...
- mechanism.
...
- Each
...
- Tomcat
...
- server
...
- is
...
- load
...
- balanced
...
- between
...
- the
...
- three
...
- Apache
...
- servers.
No Format |
---|
WSD /|{ { { \ } } } / | { { { \ } } } Apache1 Apache2 Apache3 /|\ /|\ /|{ { { \ } } } / | \ / | \ / | { { { \ } } } tomcat1 tomcat2 tomcat3 |
Building and Configuring Apache
No Format |
---|
./configure --prefix=/usr/local/apache2 --enable-so --enable-vhost-alias |
Copied mod_jk2.so
to /usr/local/apache2/modules
.
Add the following lines to httpd.conf
:
No Format |
---|
LoadModule jk2_module modules/mod_jk2.so <IfModule mod_jk.c> JkWorkersFile conf/workers2.properties </IfModule> |
...
If you are using Apache 1.3, you might try this instead:
No Format |
---|
JkSet config:file |
...
/usr/local/tomcat/conf/jk/workers2.properties |
More:)
No Format |
---|
# Default DocumentRoot # DocumentRoot "/usr/local/apache2/htdocs" <location "/*.jsp"> JkUriSet group loadbalancer </location> <location "/servlet/*"> JkUriSet group loadbalancer </location> <location "/test/*"> JkUriSet group loadbalancer </location> |
workers2.properties
No Format |
---|
# workers2.properties # # Tomcat shared memory component ["shm"] info=Scoreboard required for reconfiguration and status with multiprocess servers file=/usr/local/apache2/logs/jk2.shm size=1048576 debug=0 disabled=0 # Status worker [status:] info=Status worker, displays runtime informations [uri:/jkstatus/*] info=Display status information and checks the config file for changes. group=status: # Define Load Balancer worker [lb:loadbalancer] info=Default load balancer debug=0 # Define the loadbalancer group communication channel(s) [channel.socket:10.1.1.14:8009] port=8009 host=10.1.1.14 tomcatId=tomcat1 group=loadbalancer [channel.socket:10.1.1.15:8009] port=8009 host=10.1.1.15 tomcatId=tomcat2 group=loadbalancer [channel.socket:10.1.1.16:8009] port=8009 host=10.1.1.16 tomcatId=tomcat3 group=loadbalancer |
server.xml
Added jvmRoute="<unique tomcat id>"
to the following line:
No Format |
---|
<!-- Define the top level container in our container hierarchy --> <Engine jvmRoute="tomcat1" name="Standalone" defaultHost="localhost" debug="0"> |
This jvmRoute
parameter uniquely identifies the Tomcat server to each Apache server and maintains a sticky session between the two during a user's session.
...