使用多个 CATALINA_BASE 在 windows 上设置 tomcat 6 实例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1794444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
use multiple CATALINA_BASE to setup tomcat 6 instances on windows
提问by robinmag
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?
tomcat 发行版自带的 RUNNING.txt 表示使用 CATALINA_BASE 变量来启用多个 tomcat 实例。但是如何为每个 tomcat 实例目录设置 CATALINA_BASE 环境变量?
回答by Andy Gherna
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):
在您的开发机器上拥有多个 Tomcat 实例非常棒。以下是我通常在 Windows 上的做法(设置的重要部分在步骤 2、3、4 和 5):
- Install a copy of Tomcat 6 to a directory (like C:\apache-tomcat-6.0.20).
- Copy the confdirectory to another directory (like C:\tomcat-1)
- Under C:\tomcat-1, create a bindirectory
In the C:\tomcat-1\bindirectory, create a file called startup.batthat reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\startup.bat
In the C:\tomcat-1\bindirectory, create a file called shutdown.batthat reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\shutdown.bat
OPTIONAL: create a file called setenv.batin the C:\tomcat-1\bindirectory to set any environment variables mentioned in C:\apache-tomcat-6.0.20\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.
- Create the logs, temp, webappsand workdirectories under C:\tomcat-1
- From the C:\tomcat-1directory, run bin\startup.bat
- Repeat for your other installs from step 2 for as many tomcat instances as you need.
- 将 Tomcat 6 的副本安装到目录(如C:\apache-tomcat-6.0.20)。
- 将conf目录复制到另一个目录(如C:\tomcat-1)
- 在C:\tomcat-1 下,创建一个bin目录
在C:\tomcat-1\bin目录中,创建一个名为startup.bat的文件,内容如下:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\startup.bat
在C:\tomcat-1\bin目录中,创建一个名为shutdown.bat的文件,内容如下:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\shutdown.bat
可选:在C:\tomcat-1\bin目录中创建一个名为setenv.bat的文件,以设置C:\apache-tomcat-6.0.20\bin\catalina.bat 中提到的任何环境变量。这是设置系统属性、JPDA 地址等的地方。
- 在C:\tomcat-1下创建logs、temp、webapps和work目录
- 从C:\tomcat-1目录,运行bin\startup.bat
- 对您需要的任意数量的 tomcat 实例重复步骤 2 中的其他安装。
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.
尽量不要将 Tomcat 安装在名称中包含空格的目录中。它应该可以工作,但你会遇到更少的问题。如果您使用 Windows 的“tomcat 即服务”选项,我不知道这将如何工作。
From here, you should be able to isolate tomcat instances. Just be sure to edit your conf\server.xmlfile 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.
从这里,您应该能够隔离 tomcat 实例。请务必编辑您的conf\server.xml文件,以便关闭端口和 HTTP 连接器端口不会干扰可能正在运行的其他 Tomcat 实例。我通常为关闭端口分配 8005、8006、8007 等值,为 HTTP 连接器端口分配 8080、8081、8082 等值。
回答by Sri
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:
有一个更简单的方法。只是不要在您的机器上将 CATALINA_HOME 定义为环境变量。startup.bat 和 shutdown.bat 已经带有以下代码:
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. :)
你应该准备好了。PS:记得编辑 server.xml 并输入一个新的端口号。:)
回答by Paul
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.
这个链接有一个对我很有效的答案。其他一些答案似乎忽略的一件事是 server.xml 文件中有多个地方必须修改。在偶然发现这个答案之前,mu tomcat 服务器在某些端口上相互竞争。我已将 HTTP/1.1 连接器端口更改为 8081,但忽略了更改其他一些显然对我的 tomcat(版本 7)很重要的端口。FWIW 我有一个 tomcat 服务版本和一个非服务版本。
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
http://www.ansoncheunghk.info/article/5-steps-install-multiple-apache-tomcat-instance-windows