You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yves Glodt <yg...@mind.lu> on 2008/06/09 14:05:45 UTC

Run several applications on different ports, isolated from each other

Hello,

I use tomcat 5.5 on debian etch, for running OpemCms, which is set up to run 
in the ROOT webapp.

I need to run now another application on tomcat, and what I think to do is to 
have another "instance" of tomcat running on another port, isolated from my 
OpenCms, with a different webapps folder as well.

To sum up:

tomcat-instance 1: port 8001 webapps-folder: /var/lib/tomcat5.5/webapps
tomcat-instance 2: port 8002 webapps-folder: /home/tomcat/webapps

Note that I do not need to to virtualhosting, since I have an ordinary apache 
2.2 in front which uses mod_proxy_ajp to redirect some of the urls to tomcat.

Also, I would prefer not to touch the debian startup scripts, nor modify any 
other distributed files. All config should be done in the tomcat config-files.

I read through the documentation, but got confused of hosts, contexts, 
servers, and connectors... :-(

Can someone explain how to achieve this configuration, or maybe provide 
example-files?

Best regards,
Yves


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Run several applications on different ports, isolated from each other

Posted by David kerber <dc...@verizon.net>.
Ben Stringer wrote:
> On Fri, 2008-06-13 at 14:35 +0200, Yves Glodt wrote:
>   
>> Hello Christopher and List,
>>
>> thank you very much for your detailed description!
>> I am currently evaluating all the possibilities to run my 2 applications side-
>> by-side.
>>
>> Another idea I came up with is:
>>
>> Use only one instance of Tomcat, but create 2 connectors, which each hold one 
>> host, and these hosts have different appBase-folders. Then my apps would been 
>> isolated, and I would connect to them via mod_proxy on their respective ports.
>>     
>
> Hi Yves,
>
> I tried both methods, and preferred running two tomcat instances. It
> does require modifications to the packaging (I did this under RedHat),
> but gives the most flexibility. The decider for me was the ability to
> run each tomcat instance as a different user id, and to be able to
> completely stop and restart each tomcat without affecting the other.
>   
That last reason is why I use separate tomcat instances:  my different 
apps have very different usage profiles; one app's busy time is the 
other one's dead time, so I can do maintenance on each of them without 
affecting the other one.

D



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Run several applications on different ports, isolated from each other

Posted by Ben Stringer <be...@burbong.com>.
On Fri, 2008-06-13 at 14:35 +0200, Yves Glodt wrote:
> Hello Christopher and List,
> 
> thank you very much for your detailed description!
> I am currently evaluating all the possibilities to run my 2 applications side-
> by-side.
> 
> Another idea I came up with is:
> 
> Use only one instance of Tomcat, but create 2 connectors, which each hold one 
> host, and these hosts have different appBase-folders. Then my apps would been 
> isolated, and I would connect to them via mod_proxy on their respective ports.

Hi Yves,

I tried both methods, and preferred running two tomcat instances. It
does require modifications to the packaging (I did this under RedHat),
but gives the most flexibility. The decider for me was the ability to
run each tomcat instance as a different user id, and to be able to
completely stop and restart each tomcat without affecting the other.

Cheers, Ben



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Run several applications on different ports, isolated from each other

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yves,

| Another idea I came up with is:
|
| Use only one instance of Tomcat, but create 2 connectors, which each
hold one
| host, and these hosts have different appBase-folders. Then my apps
would been
| isolated, and I would connect to them via mod_proxy on their
respective ports.

You can certainly use this, but it depends on your notion of "isolation"
of your webapps. Commonly-loaded classes can still communicate between
applications even if they are in different <Host>s in Tomcat.

If that's okay, then you can certainly run them in the same Tomcat instance.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhSlKMACgkQ9CaO5/Lv0PC4GACgpRNdIN1k803uhtljthDcmGNM
jSUAni6bXjXmRe4oxypftZnoEydPG2fv
=YODU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Run several applications on different ports, isolated from each other

Posted by Yves Glodt <yg...@mind.lu>.
Hello Christopher and List,

thank you very much for your detailed description!
I am currently evaluating all the possibilities to run my 2 applications side-
by-side.

Another idea I came up with is:

Use only one instance of Tomcat, but create 2 connectors, which each hold one 
host, and these hosts have different appBase-folders. Then my apps would been 
isolated, and I would connect to them via mod_proxy on their respective ports.

Does this sound good?

Regards,
Yves


p.s. This way I would not need to touch the config from the debian packages 
(which I really would like to avoid)




On Tuesday 10 June 2008, Christopher Schultz wrote:
> Yves,
>
> Yves Glodt wrote:
> | I need to run now another application on tomcat, and what I think to
>
> do is to
>
> | have another "instance" of tomcat running on another port, isolated
>
> from my
>
> | OpenCms, with a different webapps folder as well.
>
> Yep, you need another instance of Tomcat. Conceptually, it's very simple:
>
> 1. Create a new directory which will hold your new instance. This
> ~   is called CATALINA_BASE, and you'll need to set this environment
> ~   variable accordingly.
>
> ~   This directory should contain the following directories:
>
> ~   conf/
> ~   logs/      (optional, if you have no logging going here)
> ~   temp/      (optional, as TC should create this)
> ~   webapps/   (optional, if you have no auto-deployed webapps)
> ~   work/      (optional, as TC should create this)
>
> ~   The conf directory needs server.xml and web.xml. Make sure
> ~   that your <Connector>s in server.xml have unique port numbers
> ~   (i.e. default HTTP port is 8080, so check that, and the default
> ~   AJP port is 8009, so check that, too... these must be unique
> ~   across all TC instances).
>
> ~   Stick your webapps in 'webapps', obviously, unless you are
> ~   going to be declaring separate XML deployment descriptors
> ~   (ignore this if you have no idea what I'm talking about).
>
> 2. Run CATALINA_HOME/bin/startup.sh with the correct CATALINA_BASE
> ~   environment variable set. Note that CATALINA_HOME points to
> ~   the /actual/ TC install -- where the bin directory is -- and
> ~   CATALINA_BASE points to your "instance" as defined above.
>
> | tomcat-instance 1: port 8001 webapps-folder: /var/lib/tomcat5.5/webapps
> | tomcat-instance 2: port 8002 webapps-folder: /home/tomcat/webapps
>
> No problem:
>
> $ export CATALINA_BASE=/home/tomcat
> $ /var/lib/tomcat5.5/bin/startup.sh
>
> Just make sure that /home/tomcat is set up as indicated above.
>
> | Also, I would prefer not to touch the debian startup scripts, nor
>
> modify any
>
> | other distributed files. All config should be done in the tomcat
>
> config-files.
>
> That's going to be a problem, because I'm sure those scripts assume only
> a single instance of TC in the "default" location. If you want to start
> up multiple TC instances, you'll have to either:
>
> 1. Copy /etc/init.d/tomcat.sh (or whatever) to /etc/init.d/tomcat2.sh
> ~   and modify it accordingly (like setting CATALINA_BASE)
>
> 2. Write a different /etc/init.d/tomcat.sh script that somehow
> ~   identifies all TC instances and starts them separately
>
> | Can someone explain how to achieve this configuration, or maybe provide
> | example-files?
>
> The documentation is available in the RUNNING.txt file that should be
> packaged with Tomcat. If you can't find that file, as the Debian folks
> why they removed it.
>
> -chris
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Run several applications on different ports, isolated from each other

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yves,

Yves Glodt wrote:
| I need to run now another application on tomcat, and what I think to
do is to
| have another "instance" of tomcat running on another port, isolated
from my
| OpenCms, with a different webapps folder as well.

Yep, you need another instance of Tomcat. Conceptually, it's very simple:

1. Create a new directory which will hold your new instance. This
~   is called CATALINA_BASE, and you'll need to set this environment
~   variable accordingly.

~   This directory should contain the following directories:

~   conf/
~   logs/      (optional, if you have no logging going here)
~   temp/      (optional, as TC should create this)
~   webapps/   (optional, if you have no auto-deployed webapps)
~   work/      (optional, as TC should create this)

~   The conf directory needs server.xml and web.xml. Make sure
~   that your <Connector>s in server.xml have unique port numbers
~   (i.e. default HTTP port is 8080, so check that, and the default
~   AJP port is 8009, so check that, too... these must be unique
~   across all TC instances).

~   Stick your webapps in 'webapps', obviously, unless you are
~   going to be declaring separate XML deployment descriptors
~   (ignore this if you have no idea what I'm talking about).

2. Run CATALINA_HOME/bin/startup.sh with the correct CATALINA_BASE
~   environment variable set. Note that CATALINA_HOME points to
~   the /actual/ TC install -- where the bin directory is -- and
~   CATALINA_BASE points to your "instance" as defined above.

| tomcat-instance 1: port 8001 webapps-folder: /var/lib/tomcat5.5/webapps
| tomcat-instance 2: port 8002 webapps-folder: /home/tomcat/webapps

No problem:

$ export CATALINA_BASE=/home/tomcat
$ /var/lib/tomcat5.5/bin/startup.sh

Just make sure that /home/tomcat is set up as indicated above.

| Also, I would prefer not to touch the debian startup scripts, nor
modify any
| other distributed files. All config should be done in the tomcat
config-files.

That's going to be a problem, because I'm sure those scripts assume only
a single instance of TC in the "default" location. If you want to start
up multiple TC instances, you'll have to either:

1. Copy /etc/init.d/tomcat.sh (or whatever) to /etc/init.d/tomcat2.sh
~   and modify it accordingly (like setting CATALINA_BASE)

2. Write a different /etc/init.d/tomcat.sh script that somehow
~   identifies all TC instances and starts them separately


| Can someone explain how to achieve this configuration, or maybe provide
| example-files?

The documentation is available in the RUNNING.txt file that should be
packaged with Tomcat. If you can't find that file, as the Debian folks
why they removed it.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhO74oACgkQ9CaO5/Lv0PAOMgCgteGLh9JSJCYeJ0pmrHIZVa3x
jocAni/LufRQ4LXwFp3H9tRGtYmSH4aG
=tRmh
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org