Step 1: Install the Tomcat files
Download Tomcat 4.1 or 5.5, and unzip it into an appropriate directory. I usually put it in /usr/local, so it ends up in a directory called /usr/local/apache-tomcat-5.5.17 (5.5.17 being the current version as of this writing), and make a symlink named /usr/local/tomcat to that directory. When later versions come out, I can unzip them and relink, leaving the older version in case things don’t work out (which rarely if ever happens, but I’m paranoid).
Step 2: Make directories for each instance
For each instance of Tomcat you’re going to run, you’ll need a directory that will be CATALINA_BASE. For example, you might make them /var/tomcat/serverA and /var/tomcat/serverB.
In each of these directories you need the following subdirectories: conf, logs, temp, webapps, and work.
Put a server.xml and web.xml file in the conf directory. You can get these from the conf directory of the directory where you put the tomcat installation files, although of course you should tighten up your server.xml a bit.
The webapps directory is where you’ll put the web applications you want to run on the particular instance of Tomcat.
I like to have the Tomcat manager webapp installed on each instance, so I can play with the webapps, and see how many active sessions there are. See my instructions for configuring the Tomcat manager webapp.
Step 3: Configure the ports and/or addresses for each instance
Tomcat listens to at least two network ports, one for the shutdown command, and one or more for accepting requests. Two instances of Tomcat can’t listen to the same port number on the same IP address, so you will need to edit your server.xml files to change the ports they listen to.
The first port to look at is the shutdown port. This is used by the command line shutdown script (actually, but the Java code it runs) to tell the Tomcat instance to shut itself down. This port is defined at the top of the server.xml file for the instance.
<Server port="8001" shutdown="_SHUTDOWN_COMMAND_" debug="0">
Make sure each instance uses a different port value. The port value will normally need to be higher than 1024, and shouldn’t conflict with any other network service running on the same system. The shutdown string is the value that is sent to shut the server down. Note that Tomcat won’t accept shutdown commands that come from other machines.
Unlike the other ports Tomcat listens to, the shutdown port can’t be configured to listen to its port on a different IP address. It always listens on 127.0.0.1.
The other ports Tomcat listens to are configured with the <Connector> elements, for instance the HTTP or JK listeners. The port attribute configures which port to listen to. Setting this to a different value on the different Tomcat instances on a machine will avoid conflict.
Of course, you’ll need to configure whatever connects to that Connector to use the different port. If a web server is used as the front end using mod_jk, mod_proxy, or the like, then this is simple enough - change your web server’s configuration.
In some cases you may not want to do this, for instance you may not want to use a port other than 8080 for HTTP connectors. If you want all of your Tomcat intances to use the same port number, you’ll need to use different IP addresses. The server system must be configured with multiple IP addresses, and the address attribute of the <Connector> element for each Tomcat instance will be set to the appropriate IP address.
Step 4: Startup
Startup scripts are a whole other topic, but here’s the brief rundown. The main different from running a single Tomcat instance is you need to set CATALINA_BASE to the directory you set up for the particular instance you want to start (or stop). Here’s a typical startup routine:
JAVA_HOME=/usr/java
JAVA_OPTS="-Xmx800m -Xms800m"
CATALINA_HOME=/usr/local/tomcat
CATALINA_BASE=/var/tomcat/serverA
export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_BASE
$CATALINA_HOME/bin/catalina.sh start
http://kief.com/running-multiple-tomcat-instances-on-one-server.html
分享到:
相关推荐
Linux下,tomcat自动获取CATALINA_HOME的脚本,放到startup.sh同级目录下即可
- `CATALINA_BASE`则是指某个特定Tomcat实例的工作目录,包含了日志、临时文件等。 #### 四、具体步骤 **4.1 修改系统环境变量** 在Debian 6中,可以通过编辑`/etc/profile`文件来添加新的环境变量。示例代码如下:...
值得注意的是,Tomcat早期版本中使用的是TOMCAT_HOME来表示Tomcat的安装目录,但是从Tomcat 4版本开始,由于Tomcat开始使用名为Catalina的新***t容器,因此环境变量的名字被相应地更改为CATALINA_HOME。 如果用户不...
1. 移除了对换变量中配置的CATALINA_HOME和CATALINE_BASE的依赖,运行startup.bat就一定是启动当前的tomcat。 2. 删除了webapps里的所有文件夹,避免未删除的ROOT目录与server.xml中的context配置发生冲突可能导致...
例如,Tomcat提供了`org.apache.catalina`包,其中包含了容器管理、会话管理、部署和生命周期管理等核心组件。此外,还有`org.apache.coyote`包,用于处理请求/响应协议,如HTTP/1.1。 3. **Tomcat AJP API**: AJP...
Tomcat 的三个最重要的启动脚本: startup.bat catalina.bat setclasspath.bat 上一篇咱们分析了 startup.bat 脚本 这一篇咱们来分析 catalina.bat 脚本. 至于 setclasspath.bat 这个脚本, 相信看完这一篇, 就可以...
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-9.0.0.M4 PATH=$PATH:$CATALINA_BASE/bin export PATH CATALINA_BASE 保持并推出:wq! 具体安装请查阅: https://www.w3cschool.cn/chenyh/chenyh-wdqt2p1n.html
CATALINA_BASE=c:\tomcat 然后修改环境变量中的classpath,把tomat安装目录下的common\lib下的(可以根据实际追加)servlet.jar追加到classpath中去,修改后的classpath如下: classpath=.;%JAVA_HOME%\lib\...
最完整的Tomcat安装,支持,init.d脚本,应用程序命名,巨大页面,强化,漂亮的错误页面,sha512哈希密码,JMX配置,多个Tomcat版本,分开的catalina_home和caralina_base。 目录 要求 没有。 安装 ansible-galaxy ...
|%CATALINA_BASE%\bin\cronolog %CATALINA_BASE%\logs\catalina.%%Y-%%m-%%d.out >> null ``` - 这段代码的作用是在每次Tomcat执行动作时(如启动、停止),通过`cronolog`工具将当前的日志输出重定向到一个新的...
- **路径一致性**:确保`CATALINA_HOME`、`CATALINA_BASE`和`TOMCAT_HOME`的值保持一致,除非在特定场景下需要它们指向不同的位置。 - **路径格式**:Windows系统中路径应使用反斜杠(`\`)而非正斜杠(`/`)。例如,...
主要涉及的环境变量包括`TOMCAT_HOME`、`CATALINA_HOME`、`CATALINA_BASE`以及`JAVA_HOME`等。 ### 二、`TOMCAT_HOME`与`CATALINA_HOME` `TOMCAT_HOME`通常被定义为Tomcat的根目录路径,即Tomcat的安装目录。这个...
7. 删除和重启:删除$CATALINA_BASE/conf/logging.properties文件,并重启Tomcat服务器,使配置生效。 通过以上步骤,Tomcat服务器将使用Log4j来管理catalina.out日志,这不但解决了日志文件过大和格式不统一的问题...
CATALINA_BASE1=E:\software\apache-tomcat-7.0.47copy CATALINA_BASE=E:\software\apache-tomcat-7.0.47 CATALINA_HOME1=E:\software\apache-tomcat-7.0.47copy CATALINA_HOME=E:\software\apache-tomcat-7.0.47 ...
CATALINA_BASE=/opt/ivms/tomcat7 CATALINA_HOME=/opt/ivms/tomcat7 TOMCAT_HOME=/opt/ivms/tomcat7 export CATALINA_BASE CATALINA_HOME TOMCAT_HOME # uimp Tomcat实例 CATALINA_2_BASE=/opt/uimp/tomcat7 ...
**CATALINA_BASE** 环境变量表示Tomcat的安装目录,即Tomcat的根目录。例如,如果Tomcat安装在 `E:\site\tools\tomcat6` 下,则可以这样设置 **CATALINA_BASE**: ``` CATALINA_BASE=E:\site\tools\tomcat6 ``` 这...
其中,CATALINA_HOME 变量用于指定 Tomcat 的安装目录,而 CATALINA_BASE 变量用于指定 Tomcat 的基础目录。了解这两个变量的作用非常重要,因为它们直接影响 Tomcat 的启动和运行。 二、多个 Tomcat 实例的配置 ...
1. 启动Tomcat:在命令行中输入“startup.bat”(在"CATALINA_HOME\bin"目录下),或者通过双击“startup.bat”文件启动Tomcat。 2. 测试运行:在浏览器中输入"http://localhost:8080",如果Tomcat已成功启动,你...
export CATALINA_BASE=/usr/local/tomcat6 export CLASSPATH=$CLASSPATH:$TOMCAT_HOME/common/lib/servlet.jar export PATH=$PATH:$CATALINA_HOME/lib ``` 3. **使环境变量生效**: ```bash source /etc/...