[英]Tomcat - CATALINA_BASE and CATALINA_HOME variables
I have multiple instances of tomcat 6 running on the same server (Linux) and it works as expected.我在同一台服务器 (Linux) 上运行了多个 tomcat 6 实例,并且它按预期工作。 I am trying to find out what the standard practice is with regards to setting the
CATALINA_HOME
and CATALINA_BASE
variables.我试图找出关于设置
CATALINA_HOME
和CATALINA_BASE
变量的标准做法是什么。
In my tomcat installation, I have setup CATALINA_HOME
to point to a "common" folder (say /tomcat6
) and the CATALINA_BASE
variable varies depending on the instance name (say /tomcat_instance1
, /tomcat_instance2
)在我的 tomcat 安装中,我已将
CATALINA_HOME
设置为指向“公共”文件夹(例如/tomcat6
),并且CATALINA_BASE
变量因实例名称而异(例如/tomcat_instance1
、 /tomcat_instance2
)
My question is this:我的问题是这样的:
CATALINA_HOME
and do away with CATALINA_BASE
(or vice-versa) ?CATALINA_HOME
并取消CATALINA_BASE
(反之亦然)吗?If you are running multiple instances of Tomcat on a single host you should set CATALINA_BASE
to be equal to the .../tomcat_instance1
or .../tomcat_instance2
directory as appropriate for each instance and the CATALINA_HOME
environment variable to the common Tomcat installation whose files will be shared between the two instances.如果您在单个主机上运行多个 Tomcat 实例,您应该将
CATALINA_BASE
设置为与每个实例对应的.../tomcat_instance1
或.../tomcat_instance2
目录,并将CATALINA_HOME
环境变量设置为公共 Tomcat 安装的文件将在两个实例之间共享。
The CATALINA_BASE
environment is optional if you are running a single Tomcat instance on the host and will default to CATALINA_HOME
in that case.如果您在主机上运行单个 Tomcat 实例,则
CATALINA_BASE
环境是可选的,并且在这种情况下将默认为CATALINA_HOME
。 If you are running multiple instances as you are it should be provided.如果您按原样运行多个实例,则应提供它。
There is a pretty good description of this setup in the RUNNING.txt
file in the root of the Apache Tomcat distribution under the heading Advanced Configuration - Multiple Tomcat Instances在 Apache Tomcat 发行版根目录下的
RUNNING.txt
文件中,在Advanced Configuration - Multiple Tomcat Instances标题下对此设置有很好的描述
CATALINA_HOME
vs CATALINA_BASE
CATALINA_HOME
VS CATALINA_BASE
If you're running multiple instances, then you need both variables, otherwise only CATALINA_HOME
.如果您正在运行多个实例,那么您需要两个变量,否则只需要
CATALINA_HOME
。
In other words: CATALINA_HOME
is required and CATALINA_BASE
is optional.换句话说:
CATALINA_HOME
是必需的, CATALINA_BASE
是可选的。
CATALINA_HOME
represents the root of your Tomcat installation. CATALINA_HOME
代表 Tomcat 安装的根目录。
Optionally, Tomcat may be configured for multiple instances by defining
$CATALINA_BASE
for each instance.或者,可以通过为每个实例定义
$CATALINA_BASE
来为多个实例配置 Tomcat。 If multiple instances are not configured,$CATALINA_BASE
is the same as$CATALINA_HOME
.如果未配置多个实例,则
$CATALINA_BASE
与$CATALINA_HOME
相同。
See: Apache Tomcat 7 - Introduction请参阅: Apache Tomcat 7 - 介绍
Running with separate CATALINA_HOME
and CATALINA_BASE
is documented in RUNNING.txt which say:使用单独的
CATALINA_HOME
和CATALINA_BASE
运行记录在 RUNNING.txt 中,其中说:
The
CATALINA_HOME
andCATALINA_BASE
environment variables are used to specify the location of Apache Tomcat and the location of its active configuration, respectively.CATALINA_HOME
和CATALINA_BASE
环境变量分别用于指定 Apache Tomcat 的位置及其活动配置的位置。You cannot configure
CATALINA_HOME
andCATALINA_BASE
variables in thesetenv
script, because they are used to find that file.您不能在
setenv
脚本中配置CATALINA_HOME
和CATALINA_BASE
变量,因为它们用于查找该文件。
For example:例如:
(4.1) Tomcat can be started by executing one of the following commands:
(4.1) Tomcat可以通过执行以下命令之一来启动:
%CATALINA_HOME%\\bin\\startup.bat (Windows) $CATALINA_HOME/bin/startup.sh (Unix)
or
或者
%CATALINA_HOME%\\bin\\catalina.bat start (Windows) $CATALINA_HOME/bin/catalina.sh start (Unix)
In many circumstances, it is desirable to have a single copy of a Tomcat binary distribution shared among multiple users on the same server.
在许多情况下,希望在同一服务器上的多个用户之间共享 Tomcat 二进制分发的单个副本。 To make this possible, you can set the
CATALINA_BASE
environment variable to the directory that contains the files for your 'personal' Tomcat instance.为了实现这一点,您可以将
CATALINA_BASE
环境变量设置为包含“个人”Tomcat 实例文件的目录。When running with a separate
CATALINA_HOME
andCATALINA_BASE
, the files and directories are split as following:当使用单独的
CATALINA_HOME
和CATALINA_BASE
运行时,文件和目录拆分如下:In
CATALINA_BASE
:在
CATALINA_BASE
:
bin
- Only: setenv.sh (*nix) or setenv.bat (Windows), tomcat-juli.jarbin
- 仅:setenv.sh (*nix) 或 setenv.bat (Windows)、tomcat-juli.jarconf
- Server configuration files (including server.xml)conf
- 服务器配置文件(包括 server.xml)lib
- Libraries and classes, as explained belowlib
- 库和类,如下所述logs
- Log and output fileslogs
- 日志和输出文件webapps
- Automatically loaded web applicationswebapps
- 自动加载的 Web 应用程序work
- Temporary working directories for web applicationswork
- Web 应用程序的临时工作目录temp
- Directory used by the JVM for temporary files>temp
- JVM 用于临时文件的目录>In
CATALINA_HOME
:在
CATALINA_HOME
:
bin
- Startup and shutdown scriptsbin
- 启动和关闭脚本lib
- Libraries and classes, as explained belowlib
- 库和类,如下所述endorsed
- Libraries that override standard "Endorsed Standards".endorsed
- 覆盖标准“认可标准”的库。 By default it's absent.默认情况下它不存在。
The easiest way to check what's your CATALINA_BASE
and CATALINA_HOME
is by running startup.sh
, for example:检查您的
CATALINA_BASE
和CATALINA_HOME
的最简单方法是运行startup.sh
,例如:
$ /usr/share/tomcat7/bin/startup.sh
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
You may also check where the Tomcat files are installed, by dpkg
tool as below (Debian/Ubuntu):您还可以通过
dpkg
工具检查 Tomcat 文件的安装位置,如下所示(Debian/Ubuntu):
dpkg -L tomcat7-common
I can't say I know the best practice, but here's my perspective.我不能说我知道最佳实践,但这是我的观点。
Are you using these variables for anything?您是否将这些变量用于任何用途?
Personally, I haven't needed to change neither, on Linux nor Windows, in environments varying from development to production.就个人而言,无论是在 Linux 还是 Windows 上,从开发到生产的不同环境中,我都不需要更改。 Unless you are doing something particular that relies on them, chances are you could leave them alone.
除非您正在做一些依赖于它们的特定事情,否则您很可能可以不理会它们。
catalina.sh
sets the variables that Tomcat needs to work out of the box. catalina.sh
设置 Tomcat 开箱即用所需的变量。 It also says that CATALINA_BASE
is optional:它还说
CATALINA_BASE
是可选的:
# CATALINA_HOME May point at your Catalina "build" directory.
#
# CATALINA_BASE (Optional) Base directory for resolving dynamic portions
# of a Catalina installation. If not present, resolves to
# the same directory that CATALINA_HOME points to.
I'm pretty sure you'll find out whether or not your setup works when you start your server.我很确定您会在启动服务器时发现您的设置是否有效。
Pointing CATALINA_BASE
to a different directory from CATALINA_HOME
allows you to separate the configuration directory from the binaries directory.指着
CATALINA_BASE
从不同的目录CATALINA_HOME
允许您配置目录从二进制文件目录分开。
By default, CATALINA_BASE
(configurations) and CATALINA_HOME
(binaries) point to the same folder, but separating the configurations from the binaries can help you to run multiple instances of Tomcat side by side without duplicating the binaries.默认情况下,
CATALINA_BASE
(配置)和CATALINA_HOME
(二进制文件)指向同一个文件夹,但将配置与二进制文件分开可以帮助您并行运行多个 Tomcat 实例,而无需复制二进制文件。
It is also useful when you want to update the binaries, without modifying, or needing to backup/restore your configuration files for Tomcat.当您想要更新二进制文件而不修改或需要备份/恢复 Tomcat 的配置文件时,它也很有用。
There is an easier way to set CATALINA_BASE now with the makebase
utility.现在有一种更简单的方法可以使用
makebase
实用程序来设置 CATALINA_BASE。 I have posted a tutorial that covers this subject at http://blog.rasia.io/blog/how-to-easily-setup-lucee-in-tomcat.html along with a video tutorial at https://youtu.be/nuugoG5c-7M我在http://blog.rasia.io/blog/how-to-easily-setup-lucee-in-tomcat.html 上发布了一个涵盖这个主题的教程以及一个在https://youtu.be上的视频教程/nuugoG5c-7M
To take advantage of this feature, simply create the config directory and point to it with the CATALINA_BASE
environment variable.要利用此功能,只需创建 config 目录并使用
CATALINA_BASE
环境变量指向它。 You will have to put some files in that directory:您必须在该目录中放置一些文件:
conf
directory from the original Tomcat installation directory, including its contents, and ensure that Tomcat has read permissions to it.conf
目录,包括其内容,并确保Tomcat对其具有读取权限。 Edit the configuration files according to your needs.logs
directory if conf/logging.properties
points to ${catalina.base}/logs
, and ensure that Tomcat has read/write permissions to it.conf/logging.properties
指向${catalina.base}/logs
,则创建一个logs
目录,并确保 Tomcat 对其具有读/写权限。temp
directory if you are not overriding the default of $CATALINA_TMPDIR
which points to ${CATALINA_BASE}/temp
, and ensure that Tomcat has write permissions to it.${CATALINA_BASE}/temp
的$CATALINA_TMPDIR
的默认值,请创建一个temp
目录,并确保 Tomcat 对其具有写入权限。work
directory which defaults to ${CATALINA_BASE}/work
, and ensure that Tomcat has write permissions to it.${CATALINA_BASE}/work
的work
目录,并确保 Tomcat 对其具有写入权限。CATALINA_BASE is optional. CATALINA_BASE 是可选的。
However, in the following scenarios it helps to setup CATALINA_BASE that is separate from CATALINA_HOME.但是,在以下场景中,设置与 CATALINA_HOME 分开的 CATALINA_BASE 会有所帮助。
When more than 1 instances of tomcat are running on same host当 1 个以上的 tomcat 实例在同一台主机上运行时
Separation of concern (Single responsibility)关注点分离(单一责任)
That is the parent folder of bin which contains tomcat.exe file:那是包含 tomcat.exe 文件的 bin 的父文件夹:
CATALINA_HOME='C:\Program Files\Apache Software Foundation\Tomcat 6.0'
CATALINA_BASE
is the same as CATALINA_HOME
. CATALINA_BASE
与CATALINA_HOME
相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.