tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Tomcat
Date Wed, 06 Feb 2013 16:34:27 GMT
Mark Eggers wrote:
> On 2/6/2013 3:20 AM, Mohit.Garg@rbs.com wrote:
>>
>> Hi Thanks for all the help and I know it may sound lame but I am
>> trying to learn these things. Although I have one more doubt. If we
>> have multiple tomcat for multiple environment on the single Unix
>> box(machine) Now Single Apache daemon is running for multiple
>> environment. So can we run multiple instance of Apache daemon in the
>> same machine or not for each different environment. If this is
>> possible how can we accomplish this.
>>
>> Thanks in advance for the help and sorry for bugging the group with
>> such silly questions.
>>
>> MOHIT GARG Analyst International Banking RBS Block No 1, Tower A,
>> Unitech Infospace Complex Sector 21, Gurgaon, Haryana, 122002, India
>> Office: +91 8860190177
>>
>> -----Original Message----- From: André Warnier
>> [mailto:aw@ice-sa.com] Sent: 06 February 2013 16:21 To: Tomcat Users
>> List Subject: Re: Tomcat
>>
>> Mohit.Garg@rbs.com wrote:
>>> Hi
>>>
>>> Regrets for the wrong framing of question. Actually I am new to
>>> tomcat and what I really want to do is run on the same server two
>>> different tomcats so that one doesn't interfere with the working of
>>> the other. As I have different environments so I want that the
>>> tomcat running in my development environment do not access the
>>> files of my SIT environment and vice-versa. That's why I want to
>>> have a separate tomcat process for each host. If I just change the
>>> port in the config file the request will be mapped but the various
>>> environments will have access to all the files as it will be
>>> present in the common directory.
>>>
>>
>> Ah, that's better. So we forget about Apache httpd, right ? So,
>> assuming that you are talking about tomcat only :
>>
>> There are (many) different levels of separation, depending on what
>> you really want to separate.
>>
>> First, a note : considering that you are on a Linux machine, it is
>> highly possible that you have installed Tomcat using a pre-packaged
>> version from your Linux distribution. These packages work fine and
>> are easy to install for a normal single-instance case, but they make
>> it more difficult for doing the kind of thing that you want to do,
>> and more difficult for people on this list to help you.  That is
>> because each of these packages distributes the files of Tomcat in
>> different places on the disk, sets different environment variables,
>> sets differents links from one directory to the other in the
>> filesystem, etc.. So it would be better to install a "standard"
>> tomcat downloaded from the website "tomcat.apache.org", to some
>> directory like /opt/tomcat, and follow the instructions that are
>> given in the "RUNNING.txt" file at the top of this distribution. This
>> way, everyone here knows what you are talking about and has a good
>> idea of where things are. (You can also leave your current Tomcat
>> where it is, and consider it as your "production" tomcat, and
>> download and install another copy to another directory as your
>> "development" tomcat. Then we can maybe help you set up this
>> development tomcat in a way that does not conflict with the other
>> one).
>>
>> Then, the next question is : you want to run 2 "separate" tomcats, so
>> as not to mix the production and the development environments. That's
>> established. But do you want also to be able to run 2 different
>> /versions/ of Tomcat ?
>>
>> If yes, you will have to download and install tomcat twice, to 2
>> separate directories in /opt (such as /opt/tomcat-prod and
>> /opt/tomcat-dev for instance). If not, then one single copy of tomcat
>> will be enough, and you can configure things to still run 2 different
>> "instances" of tomcat, from one single copy of the code.
>>
>>
>> Then, some advance information : There are 2 environment variables
>> which point to disk directories and which are very important for what
>> you want to do :
>>
>> CATALINA_HOME : this tells Tomcat where its runnable *code* is
>> located.  under CATALINA_HOME, Tomcat expects to find for example
>> it's "bin" subdirectory, where the main executable parts of Tomcat
>> are located.
>>
>> CATALINA_BASE : this tells Tomcat where its instance-specific
>> "things" are located. For example, Tomcat will look into
>> $CATALINA_BASE/conf to find its main configuration files.
>>
>> By default, these 2 values are the same, and Tomcat will use the same
>> /bin, /conf etc..
>>
>> But you can set up 2 tomcat instances to use the same $CATALINA_HOME
>> directory (so they will run the same Tomcat code from
>> $CATALINA_HOME/bin), but have different $CATALINA_BASE directories
>> (so they will use a different configuration from $CATALINA_BASE/conf,
>> different webapps from $CATALINA_BASE/webapps etc).
>>
>> That's the basics for separating two tomcat instances.
>>
>> Note that there is still a much easier way, using a single Tomcat
>> instance and just 2 separate "virtual hosts" inside the same running
>> Tomcat (see :
>> http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html).
>> The hostnames will be different, and the webapps will be completely
>> separate.  But there will still be one single instance of tomcat
>> running, and there /could/ be interference between them (not at the
>> access level, but in the sense that one webapp could use up all the
>> memory and so interfere with the other e.g.).
>>
> 
> +1 for all tha André has said.
> 
> (Mark-like novella typing detected above :p)
> 
> Anyway, what we do is the following:
> 
> 1. One Apache HTTPD
> 
> This runs named virtual hosts and IP-based virtual hosts (see the Apache 
> HTTPD docs and the Apache HTTPD mailing list)
> 
> 2. mod_jk between Apache HTTPD and multiple Tomcats
> 
> 2a. Each Tomcat gets its own worker.properties configuration
> 
> See http://tomcat.apache.org/connectors-doc/reference/workers.html for 
> details. There are great examples in the recent mod_jk source  bundle.
> 
> 2b. Each named virtual host gets its own uriworkermap.properties file
> 
> See http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html 
> for details. There are great examples in the recent mod_jk source bundle.
> 
> 3. Tomcat configuration
> 
> 3a. Make sure that each Tomcat has a <Host> element that corresponds to 
> each Apache named virtual host (or IP-based virtual host) that it's 
> responsible for.
> 
> 3b. Make sure that the ports are different for each Tomcat.
> (Shutdown port, AJP port, any HTTP/1.1 ports)
> 
> 4. Run each Tomcat as a separate service
> 
> We use a separate start-up script for each. Each start-up script reads 
> from a configuration file that has CATALINA_HOME, CATALINA_BASE, and 
> JRE_HOME defined. This means we can run different JVMs for different 
> Tomcats, and upgrade each Tomcat separately.
> 
> 5. As André pointed out, run a stock Tomcat from tomcat.apache.org
> 
> 6. Run all of the Tomcats from an unprivileged account
> 
> We make the account only accessible via su, control access, and monitor 
> its use. This makes auditing much easier.
> 
> I'm sure there is more, but this is quite long enough as it is.
> 
> . . . . just my two cents.

+1 (mutual admiration society, one hand washes the other etc.)

P.S. Do I detect some Mark-like novella-typing here too ?


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


Mime
View raw message