`
lhh_hoo
  • 浏览: 17077 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Running multiple Tomcat instances on one server

阅读更多

 

Here's a brief step by step guide to running more than one instance of Tomcat on a single machine.

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_HOME . 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
分享到:
评论

相关推荐

    Making Multiple Instances of an Application run in the Same

    Making Multiple Instances of an Application run in the Same Process Space as different Threads (56KB)

    MITI Multiple Instances Tomcat Installer-开源

    【MITI Multiple Instances Tomcat Installer】是一个开源项目,旨在简化多实例Tomcat的部署和管理。这个工具的主要目的是帮助用户快速、高效地安装并配置多个独立的Tomcat服务器实例,而无需手动完成一系列复杂的...

    SQL Server AlwaysOn Revealed(Apress,2ed,2016)

    This is a practical and hand-on book to get you started quickly in using one of the most talked-about SQL Server feature sets. Teaches you to build HA and DR solutions using the AlwaysOn feature set...

    Manage Multiple Instances of OSPF with SNMP Contexts [IP Application Services] - Cisco Systems

    Manage Multiple Instances of OSPF with SNMP Contexts [IP Application Services] - Cisco Systems

    tomcat-5.5.23

    server as if you were using J2SE 5.0. &lt;br&gt; ================================================== Advanced Configuration - Multiple Tomcat Instances ===========================================...

    AlwaysOn安装配置

    AlwaysOn主要包含两部分技术:AlwaysOn可用性组(AlwaysOn Availability Groups)和AlwaysOn故障转移集群实例(AlwaysOn Failover Cluster Instances)。AlwaysOn可用性组允许将数据库以分组的形式,进行故障转移和...

    weka源码解析 instances类

    ### Weka源码解析:Instances类详解 #### 一、Weka及Instances类简介 Weka是一款开源的数据挖掘工具,支持多种数据预处理、分类、回归、聚类、关联规则等机器学习算法,并且提供了丰富的图形用户界面以及API接口。...

    instances_minival2014.json和instances_valminusminival2014.json

    《深度学习数据集的标注与验证:以instances_minival2014.json和instances_valminusminival2014.json为例》 在计算机视觉领域,数据集是模型训练的基础,而有效的标注则决定了模型的性能。当我们谈论"instances_...

    tomcat 的安装与 集群的设定

    4. **启用集群模式**:在`server.xml`文件中配置`Cluster`节点,并为每个Tomcat实例设置一个唯一的节点ID。 5. **配置通信协议**:选择合适的通信协议,如NIO或APR,以提高性能。 通过上述步骤,可以搭建起一个...

    Docker - Clustering Payara Server in Docker

    Clustering involves running multiple instances of Payara Server that work together to provide load balancing, failover, and scalability. Here’s how to set up a cluster using Docker: ##### Load ...

    让SQL Server为工作负载高峰提前做好准备

    本文介绍了提高SQL Server解决方案在负载高峰时期的高性能的全部预备措施:高可用性通常包含了集群。当你需要较高级别的正常运转时间的时候,你需要对SQL Server进行集群。其他的高可用性方法包括地理集群,集群节点...

    instances_valminusminival2014.json和instances_minival2014.json

    《COCO标签在instances_valminusminival2014.json与instances_minival2014.json中的应用》 在计算机视觉领域,数据集的构建和标注是模型训练的基础,而COCO(Common Objects in Context)数据集是其中极具影响力的...

    Revisiting multiple instance neural networks

    The MINNs perform MIL in an end-to-end manner, which take bags with a various number of instances as input and directly output the labels of bags. All of the parameters in a MINN can be optimized via...

    Virtualizing SQL Server with VMware_English

    - **Resource Optimization**: By consolidating multiple SQL Server instances onto fewer physical servers, organizations can significantly reduce hardware costs and improve overall resource utilization....

    instances_trainval35k.

    标题“instances_trainval35k”指的是一个特定的数据集,它是针对对象检测任务的一个训练和验证集合。在计算机视觉领域,对象检测是一项重要的任务,它旨在识别和定位图像中的各个对象。这个数据集,结合了训练...

    springcloud config server 服务配置中心 服务器端

    SpringCloud Config Server 是一个在分布式系统中管理外部配置的服务,它允许你将应用的配置集中化、版本化,并且提供动态刷新的能力。这个服务作为Spring Cloud生态中的一个重要组件,为微服务架构提供了强大的配置...

    开源ocal密码爆破DOS运行_orcalpass.7z

    It will be quicker to run multiple instances of OraBrute on different machines pointing at the same server. OraBrute requires selectpassword.sql and password.txt Put your own most likely ...

    JLink_Windows_V670a.exe

    When having multiple J-Link Remote Server instances running on the same machine, it could happen that when disconnecting one client from one server, the other server also lost its connection....

    Healthy SQL.pdf

    have deployed multiple SQL Server instances in their environments, and as companies deploy various applications, many have had to deal with what’s known as SQL sprawl. This is the 1:1 ratio ...

Global site tag (gtag.js) - Google Analytics