>________________________________
> From: Aman Arora <aman.arora...@gmail.com>
>To: users@tomcat.apache.org
>Sent: Thursday, May 24, 2012 10:25 PM
>Subject: mod_jk not working !!
> 
>m trying to do a setup of tomcat clustering in which one tomcat is on port
>8080 and other one is on 8081.
>i have downloaded the tomcat-connector in the modules folder of my apache.i
>built it using build-unix.sh by downloading the script from net as it was
>nt already there in the downloaded tomcat-connector. it buit mod_jk.so
>which i have placed inside modules folder as
>/usr/local/apache2/modules/mod_jk.so
>then i created workers.properties file and gave the description of workers
>there .and included it in httpd.cong file .
>still when i type http://localhost/jsp-pages which are in my webapps / it
>is not passing requast to tomcat which is holding the js pages.
>you may hav a look at the conf files to get a better fel of the problem !
>the link is
>http://www.coderanch.com/t/581294/Tomcat/Tomcat-Clustering#2648034

OK,

I've taken a brief look at your configuration files (httpd.conf, mod_jk.conf, 
server.xml, workers.properties).

I've also taken a brief look at the Safari Books link you gave.

As Andre said (sorry about the lack of accent, Andre), people are going to be a 
bit reluctant to wade through all of that material and provide pointers.


Also as Andre has said, clustering Tomcat on the same machine works fine for 
many people. I routinely use a 3 or 4 node cluster as a test platform.

I'll try to give a few general directions. As is my usual practice, this is 
going to be long. You have been warned.

General thoughts
================

In your Code Ranch postings, you state that you are new to Linux. Getting 
clustering to work on Linux involves Apache HTTPD configuration, Tomcat 
configuration, and Linux configuration. If this is your first time doing all of 
this, it's probably best to get a simple mod_jk connection working first.

At each stage of the setup, I recommend testing and coming back to the mailing 
list with simple questions and the relevant portion(s) of the configuration 
file(s). Also, be prepared to do at least as much work as those people trying 
to help. Remember, this is a volunteer list, and we contribute in our spare 
time.

Also, as another aside . . . there is a lot of misleading, incomplete, and just 
flat wrong information concerning Tomcat floating around on the 'net. The 
authoritative source for information is always:

http://tomcat.apache.org/


The mailing list for questions is this mailing list. We try to give accurate 
information, and some people here have been working with Tomcat for a very long 
time.

You might get accurate information elsewhere, but from what I've seen this is 
not very likely.

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.

Purpose
=======

What is the purpose of this setup? If you're running a pseudo-production 
development platform, then what you're setting up may be reasonable. If you're 
setting up a development platform with NetBeans or Eclipse, then you will run 
into a lot of file access problems with your setup.

If you're setting up a development system, I recommend just creating a 
directory in your home directory to hold a single Tomcat, unpack Tomcat 7.0.27 
in that directory, edit $CATALINA_HOME/conf/tomcat-users.xml per the 
instructions, and then use that installation.

http://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. Now you can develop, debug, test, and deploy 
without running into permission issues.

If you're setting up a pseudo-production environment, then it's probably a good 
idea to set up a service account, install (and control) all Tomcats from that 
account, and connect those Tomcats to Apache HTTPD (or not). Note that since 
this is a separate account, this is a bit less convenient for development.

Apache HTTPD
============

I noticed that you have a lot of /usr/local based directories in your Apache 
HTTPD configuration. This is quite unusual for Linux, since most (all?) Linux 
distributions package 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.

On Fedora, the Apache HTTPD packages include:

apr
apr-util
apr-devel
apr-util-devel
httpd
httpd-devel
httpd-tools

The -devel packages are very important, since you will be building mod_jk from 
source.

Java
====

I from your messages that you have Oracle's Java installed. Make sure you're 
using the Java you think you're using. Type:

javac -version
java -version

on the command line and see what you get.

Tomcat
======

As I've noted above if you're setting up a pure development environment it's 
just best to create a directory in your home directory and unpack a Tomcat 
there. For now, just start with one.

If you have Java installed correctly, Tomcat comes ready to run out of the box. 
Just unpack it, cd to the bin directory, and run startup.sh. You should be able 
to browse to localhost:8080/ and see the Tomcat welcome page.

Unlike Apache HTTPD, most people here 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://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.

1. Download the source from http://tomcat.apache.org/
2. Unpack it into a directory
3. cd to [tomcat-connectors-1.xx]/native
4. Read BUILDING.txt

Briefly . . .
1.  ./configure --with-apxs=/usr/sbin/apxs
2. make
3. su to root
4. cd back to where you were
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.

Map all of the examples (not just the *.jsp files).

Restart Apache HTTPD, and then start Apache Tomcat. You should be able to 
browse to localhost/examples and get the Apache Tomcat examples.

---- IMPORTANT ----

Do not proceed with clustering until this works.

---- IMPORTANT ---- 


Please note that if you place all of your mappings in a uriworkermap.properties 
file, Apache HTTPD will reread this once per minute (by default). This is nice 
if you tend to add and delete Tomcat applications. It's probably not quite as 
nice for a production system (but I don't know what the overhead is).

Clustering
==========

There are a lot of pieces.

1. Linux

You have to ensure that multicast is enabled, and that multicast routing is set 
up. If you run iptables, you may run into firewall issues, but on the same 
system probably not.

I'll not go into the Linux configuration issues in detail at this time.

2. mod_jk

You'll have to add another host (obviously) for clustering. You'll need to name 
your workers appropriately. As noted in the documentation, each worker name 
must match the jvmRoute attribute set in your Engine.

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


You'll need to change the mapping in uriworkermap.properties to point to the 
load balancer.

3. 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.

4. Tomcat clustering configuration

The basic clustering documentation can be found here:

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

a. Make sure that each Tomcat has a unique jvmRoute in the
   Engine element
b. Make sure that the jvmRoute matches the correct worker
   name (see above)
c. Make sure that each Tomcat has a unique shutdown port
d. Make sure that each Tomcat has a unique AJP/1.3 port
e. Make sure that each AJP/1.3 port matches the correctly
   named worker in  workers.properties
f. Make sure that each HTTP/1.1 port is unique (nice for
   manager access)
g. Copy the example configuration from:

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

to inside your Host element in server.xml, but omit (for now) the Deployer 
element.

Start up your Tomcat servers.

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

==============

This above should point you in the right direction.

Again, start simply.

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

. . . just my three cents (since this is long)
/mde/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to