Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add a permalink. Fix formatting. Convert links to https.

Permalink to this page: https://cwiki.apache.org/confluence/x/DiklBg

From Zero to Clustered - an Overview

...

Also, there is a lot of misleading, incomplete, and just flat wrong information concerning Tomcat floating around on the Internet. You might get accurate information elsewhere, but from what I've seen this is not very likely. The authoritative source for information is always:

httphttps://tomcat.apache.org/

Linux in General

You'll find that Linux is a different beast than Windows (even Windows 7). In particular file permissions, file ownerships, and SELinux present quite a different security model than the typical Windows installation. It's best to be aware of this from the start.

...

If you're setting up a development platform, then just create a directory and unpack multiple Tomcat servers in that directory. This will make dealing with permissions easier, which is an important consideration when integrating Tomcat servers with IDEs such as Eclipse or NetBeans.

Apache HTTPD

Rather than building your own Apache HTTPD, I recommend that you get and install the distribution package for Apache HTTPD. This will place files in line with the rest of your system, and it will also have a serviceable default configuration.

...

Now stop the Tomcat server with shutdown.sh and set up the manager application. This involves editing the tomcat-users.xml file found in the conf directory. Instructions for editing that file (for Tomcat 7) can be found here:

httphttps://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access

Once it's running and you can access the manager application, then associate the installation with your IDE (if you're setting up a development environment). Now you can develop, debug, test, and deploy from within your IDE without running into permission issues.

Warning

Unlike Apache HTTPD, most people on the mailing list do NOT recommend that you use the Linux distribution packaged versions of Tomcat. In general people have found that these are much more difficult to work with than just getting a stock Tomcat from http https://tomcat.apache.org/

mod_jk build

While other people have had difficulty (search the mailing list) building mod_jk on various platforms, I've never had much trouble. The steps are quite simple, provided you have the appropriate packages installed on your system.

...

  1. Download

    the

    source

    from

    http

    https://tomcat.apache.org/download-connectors.cgi

    2.

  2. Unpack it into a directory
  3. 3. cd to \[tomcat-connectors-1.xx\]/native 4.
  4. Read

    BUILDING.txt

    \\

Following BUILDING.txt:

  1. ./configure --with-apxs=/usr/sbin/apxs 2.
  2. make
  3. 3. su to root
  4. 4. cd back to where you were 5.
  5. make install

This will put everything in the right place.

mod_jk configuration

...

Recent

...

versions

...

of

...

mod_jk

...

come

...

with

...

some

...

very

...

nice

...

and

...

well-commented

...

examples.

...

They

...

can

...

be

...

found

...

in

...

[tomcat-connectors-1.xx

...

]/conf.

...

Read

...

them,

...

follow

...

them,

...

use

...

them.

The defaults have been chosen to work in most general use cases.

...

See the following for documentation on worker name versus jvmRoute attribute:

httphttps://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html#Cluster_Basics

See the following for mod_jk loadbalancer configuration:

httphttps://tomcat.apache.org/connectors-doc/reference/workers.html

Another Tomcat

While the easiest way to get started with clustering is just to unpack another copy of Tomcat in another directory, it's probably far more useful to use the concept of CATALINA_HOME and CATALINA_BASE. See RUNNING.txt in the Tomcat directory for details.

...

  1. Change the SHUTDOWN port to not conflict with the first Tomcat
  2. 2. Change the HTTP/1.1 port to not conflict with the first Tomcat (useful for testing) 3.
  3. Change the AJP/1.3 port to match that configured in workers.properties 4.
  4. Change the jvmRoute attribute of the Engine element to match the correct worker name 5.
  5. Configure the manager application (useful for testing)

...

The basic clustering documentation can be found here:

httphttps://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html

It's long, involved, and needs to be read carefully. However, as a first pass the following will work.

  1. Make sure that each Tomcat has a unique jvmRoute in the Engine element (see above) 2.
  2. Make sure that the jvmRoute matches the correct worker name (see above)
  3. 3. Make sure that each Tomcat has a unique shutdown port (see above)
  4. 4. Make sure that each Tomcat has a unique AJP/1.3 port (see above)
  5. 5. Make sure that each AJP/1.3 port matches the correctly named worker in workers.properties (see above) 6.
  6. Make sure that each HTTP/1.1 port is unique (nice for manager access) 7.
  7. Copy the example configuration from :

...

  1. https://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html

...

  1. to inside the Host element in each server.xml, but omit (for now) the Deployer element. The cluster configuration can be placed inside the Host or Engine element. However, the Farm Deployer element will only work if the cluster configuration is inside the Host element.
  2. Start up your Tomcat servers. If everything is set up correctly, cluster notifications will appear in the logs.

It's also useful to have the access log enabled for your Tomcat servers. You can then tell which Tomcat is receiving the request from Apache HTTPD.

...

  1. Stock Apache HTTPD installation (and verify)
  2. 2. Stock Apache Tomcat installation (and verify) 3.
  3. mod_jk installation (and verify)
  4. 4. Second Apache Tomcat installation (and verify) 5.
  5. Cluster