English 中文(简体)
use multiple CATALINA_BASE to setup tomcat 6 instances on windows
原标题:

The RUNNING.txt that comes with tomcat distribution indicates the use of CATALINA_BASE variable to enable multiple tomcat instance. But how can I set the CATALINA_BASE environment variable for each tomcat instance directory?

最佳回答

Having multiple Tomcat instances on your development machine is great. Here s how I usually do it for Windows (the important parts for setup are in steps 2, 3, 4 and 5):

  1. Install a copy of Tomcat 6 to a directory (like C:apache-tomcat-6.0.20).
  2. Copy the conf directory to another directory (like C: omcat-1)
  3. Under C: omcat-1, create a bin directory
  4. In the C: omcat-1in directory, create a file called startup.bat that reads like this:

    set CATALINA_BASE=C: omcat-1

    set CATALINA_HOME=C:apache-tomcat-6.0.20

    C:apache-tomcat-6.0.20instartup.bat

  5. In the C: omcat-1in directory, create a file called shutdown.bat that reads like this:

    set CATALINA_BASE=C: omcat-1

    set CATALINA_HOME=C:apache-tomcat-6.0.20

    C:apache-tomcat-6.0.20inshutdown.bat

  6. OPTIONAL: create a file called setenv.bat in the C: omcat-1in directory to set any environment variables mentioned in C:apache-tomcat-6.0.20incatalina.bat. This is the place to set system properties, JPDA addresses, etc.

  7. Create the logs, temp, webapps and work directories under C: omcat-1
  8. From the C: omcat-1 directory, run binstartup.bat
  9. Repeat for your other installs from step 2 for as many tomcat instances as you need.

Try not to install Tomcat in a directory that has spaces in its name. It should work, but you ll experience fewer problems that way. I do not know how this would work if you were using the "tomcat as a service" option for Windows.

From here, you should be able to isolate tomcat instances. Just be sure to edit your confserver.xml file so that the shutdown ports and HTTP connector ports don t interfere with other Tomcat instances that may be running. I usually assign values like 8005, 8006, 8007, etc. for the shutdown port and 8080, 8081, 8082, etc. for the HTTP connector port.

问题回答

There is an easier way. Simply don t define the CATALINA_HOME as a Environment variable on your machine. startup.bat and shutdown.bat already come with the following code:

if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"

You should be all set. PS: Remember to edit server.xml and put a new port number though. :)

This link has an answer that worked well for me. One thing some of the other answers seems to ignore is that there are multiple places in the server.xml file that must be modified. Before stumbling on this answer mu tomcat servers were competing with each other for certain ports. I had changed the HTTP/1.1 connector port to 8081, but neglected to change some other ports that apparently mattered for my tomcat (version 7). FWIW I had one tomcat service version and one non-service version.

First server.xml file

<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8005" shutdown="SHUTDOWN"/>
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Second server.xml file

<connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8006" shutdown="SHUTDOWN"/>
<connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8101" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

http://www.ansoncheunghk.info/article/5-steps-install-multiple-apache-tomcat-instance-windows





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签