Using the JK2 Connector


This is the start of a tutorial on using the JK2 Connector. See also the [TomcatFAQ/ModJK2OnRedHat| Tomcat FAQ on building mod_jk2 for { { { RedHat } } } Linux].

See also HowToRedhat8JK2 for configuring redhat'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! :-)

This is working on { { { RedHat } } } 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 RUNNING.txt for 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:

 site/ ${CATALINA_BASE}                                                  

This is just a basic description for this example. There are other options for placement of the site content.


Starting and Stopping

{{{ start: 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 { { { SysVInit } } } script that manages this cleanly for many sites. The user should be in the same group as the apache web server process.


Connector {{{ { { { <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" } } }

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:

{{{ handler.list=apr,channelUnix,request


conf/work2er.properties:

{{{logger

NOTE: You must make sure that the group owning the work/ directory is the same as the Group directive in httpd.conf. Issue the following:

{{{ chgrp group work

If you have already tried tomcat before doing this, then also issue: chgrp group jk2.socket


conf.d/jk2.conf:

 { { { LoadModule jk2_module modules/mod_jk2.so } } } 


httpd.conf

{{{ # This sends all resource requests to tomcat


<B>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.</B>


FYI

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)


Building and Configuring Apache

 ./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:

{{{ { { { LoadModule jk2_module modules/mod_jk2.so } } }

(note from another author, I couldn't get apache1.3.28 to accept this, I had to use { { { JkSet config:file /usr/local/tomcat/conf/jk/workers2.properties } } })

{{{ # Default { { { DocumentRoot } } }


workers2.properties

{{{ # workers2.properties

["shm"]


server.xml

Added jvmRoute="<unique tomcat id>" to the following line:

{{{ <!-- Define the top level container in our container hierarchy -->

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.

Hope this helps...

Tomcat/Jk2Connector (last edited 2009-09-20 23:32:15 by localhost)