- 浏览: 938062 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (423)
- mysql (37)
- hibernate (3)
- struts (9)
- spring (33)
- dom4j (2)
- junit (0)
- exception (1)
- 随笔杂谈 (12)
- google app engine (1)
- XMPP (1)
- OAuth安全授权 (1)
- 版本控制 (8)
- 心情感悟 (0)
- core java (19)
- log4j (7)
- jquery (12)
- javascript (10)
- 网站性能优化及工具 (11)
- 服务器架设配置等 (38)
- EXT (4)
- 正则表达式 (5)
- 日志统计分析 (2)
- htmlparse (4)
- httpclient (5)
- java随笔 (5)
- dhtmlxtree (1)
- freemarke (5)
- memcached (6)
- javamail (5)
- Linux命令 (10)
- 应用监控cpu web jdbc等 (4)
- jmagick (9)
- 第三方缓存策略 (9)
- ORM (2)
- hadoop (2)
- 大数据量处理 (8)
- 经典 (1)
- 权限设计 (1)
- andriod (1)
- mybatis (12)
- redis (24)
- 数据结构_算法 (5)
- 分布式系统 (1)
- php (1)
- 网络编程 (3)
- 服务器部署 (3)
- ios (2)
- IM (23)
- mina (1)
- 视讯和语音 (1)
- 代码生成 (1)
- 架构 (4)
- 建模工具 (1)
- oracle (4)
- solr (10)
- 构建工具 (7)
- html5 (1)
- nginx (5)
- css (1)
- 大数据-分布式 (2)
- 设计模式 (2)
- mq (2)
- jvm调优 (8)
- 并发编程 (2)
- 搜索引擎 (1)
- UML (2)
最新评论
-
天使建站:
jquery获取网页里多选框checkbox选中项的值的方法及 ...
JS jQuery分别获取选中的复选框值 -
abao1:
发现一个小问题 sortAndSave方法中的for循环 第二 ...
完整java实现外部排序 -
西巴拉古呀那:
Kafka分布式消息系统实战(与JavaScalaHadoop ...
消息系统kafka介绍 -
kafodaote:
Kafka分布式消息系统实战(与JavaScalaHadoop ...
消息系统kafka介绍 -
成大大的:
Kafka分布式消息系统实 ...
消息系统kafka介绍
原文地址:http://azeditech.com/tomcat/multiple-tomcat-instances.html
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
补充:每个tomcat实例的启动脚本和关闭脚本必须设置的环境变量是:
CATALINA_HOME (每个实例的值都一样,指向tomcat程序的安装目录)
CATALINA_BASE (各个实例有不同的值,指向各个实例的安装目录)
JAVA_HOME或JRE_HOME (各个实例的值都一样)
例子:start.bat (Windows环境下)
- rem 每个tomcat实例的启动脚本
- rem 设置Java虚拟机的安装路径(也可以设置JDK的安装路径JAVA_HOME,二者选其一即可)
- rem ------------------------------------------------------------------
- set JRE_HOME=C:/Program Files/Java/jre6
- rem 设置CATALINA_HOME
- rem -----------------
- set CATALINA_HOME=D:/server/tomcat6_HOME
- rem 每个tomcat实例的CATALINA_BASE的值是不一样的
- rem -------------------------------------------
- set CATALINA_BASE=D:/server/tomcat6_BASE_1
- call %CATALINA_HOME%/bin/startup.bat
发表评论
-
tomcat jvm 参数说明
2013-12-17 09:50 1515maxThreads=”1000″ enableLookup ... -
SecureCRT常用快捷键设置
2013-11-27 08:36 2738http://www.tatujia.com 1:如果不 ... -
自动拒绝恶意IP远程登录Linux服务器脚本
2013-09-19 13:00 1246http://wgkgood.blog.51cto.com/ ... -
帮助中心分类 新闻公告 (10) Windows VPS教程 (13) Linux VPS教程 (28) 其他 (1) linux中Cron定时任务系统命令详解
2013-05-21 17:46 978有很多同学在购买VPS之后,需要用到计划任务.但是又对计划任 ... -
Nginx配置文件nginx.conf中文详解
2013-04-03 10:29 905#定义Nginx运行的用户和用户组user www www ... -
nginx配置相关文章
2013-04-03 10:29 902nginx配置相关文章 http://developer ... -
Nginx日志自动切割脚本
2013-04-03 10:29 989说明:每隔7天执行一次,使用crontab自动运行脚本,请 ... -
centos 6.2 64位安装nginx php mysql
2013-04-03 10:30 1776平台环境http://jiyunjie.blog.51ct ... -
centos nginx安装教程
2013-04-02 13:50 10441.安装 默认安装到/usr/local/ng ... -
Linux中iptables设置详细
2012-09-28 14:13 1550无论如何,iptables是一个需要特别谨慎设置的东西,万 ... -
CentOS 5.6Final下FTP安装及配置 .
2012-09-27 10:07 1211My Scripts: [root@localhost ~] ... -
CentOS5.6 安装JDK
2012-09-27 10:05 995首先通过界面卸载OpenJDK.然后卸载默认的jdk1.42 ... -
Java获取客户端真实IP地址的两种方法
2012-09-13 13:08 1003在JSP里,获取客户端的IP地址的方法是:request.ge ... -
令 Nginx 后端的 Apache 获取到互联网 IP
2012-09-13 10:58 1903http://blog.csdn.net/songerzhou ... -
让tomcat支持2级域名共享session
2012-09-13 10:46 1009tomcat默认情况下是不支持2级域名共享session的,所 ... -
nginx防盗链配置
2012-08-21 13:22 1232以下配置一般可称为图片防盗链配置,如果是mp3这种文件,我现在 ... -
将nginx同时作为负载均衡和Web缓存服务器
2012-02-13 11:11 1181http://server.51cto.com/sColleg ... -
nginx 代理模式下,获取客户端真实IP
2011-11-30 09:42 4829最近做博友推荐,发现个小问题,用$_SERVER['REMOT ... -
nginx相关文章地址收集
2011-11-04 14:07 1020http://bbs.chinaunix.net/thread ... -
LVS+keeplived+nginx+tomcat高可用、高性能jsp集群
2011-11-04 10:31 2058摘自:http://kerry.blog.51cto.com/ ...
相关推荐
Linux下tomcat多实例配置成功。步骤如下: 1. 下载一个免安装版本的tomcat,例如:apache-tomcat-7.0.59.tar.gz。解压:tar xvf pache-tomcat-7.0.59.tar.gz. 解压后的文件夹中大致有7个文件夹: bin (运行...
Tomcat+JSP配置实例 、、、、、
jdk,tomcat配置实例 可以下载
zabbix执行脚本自动化发现监控tomcat多实例
6. **虚拟主机配置**:如何配置多个域名指向同一Tomcat实例,实现多站点部署。 7. **日志和错误处理**:设置和查看Tomcat的日志文件,理解错误代码和解决常见问题。 8. **安全性设置**:涵盖用户认证、角色权限、 ...
Nginx+tomcat配置集群负载均衡实现动静分离实例
TomcatJSP经典配置实例
maven+tomcat+eclipse配置实例
Tomcat JSP经典配置实例
6. **虚拟主机配置**:如何在同一台机器上配置多个独立的Tomcat实例,或者在单个Tomcat中设置多个虚拟主机,以托管不同的Web应用。 7. **部署Web应用**:演示如何将WAR文件或已解压的目录放入webapps目录,以及如何...
Tomcat+JSP+MySQL经典配置实例
"Nginx负载均衡代理多个Tomcat搭建实例过程" 一、Nginx安装与配置 Nginx是一款轻量级的Web...Nginx负载均衡代理多个Tomcat搭建实例过程需要完成Nginx和Tomcat的安装和配置,配置Nginx负载均衡,并进行压力测试。
这个"一个很好的tomcat实例"很可能是包含了Tomcat的配置、示例应用程序以及可能的部署指南,旨在帮助用户更好地理解和使用Tomcat。 首先,让我们深入了解一下Tomcat的核心功能。Tomcat是Apache软件基金会Jakarta...
Eclipse 项目配置 Tomcat 步骤 在 Eclipse 中配置 Tomcat 是一个非常重要的步骤,它能够让开发者在 Eclipse 中使用 Tomcat 服务器来运行和测试 Java Web 应用程序。下面是 Eclipse 项目配置 Tomcat 的详细步骤: ...
JMS简明教程+JMS规范教程+activemq以及activemq和tomcat的整合+整合实例代码+持久化消息配置以及工程+tomcat服务器的配置+整合需要的lib文件+部署多个tomcat服务器方案等
**uriworkermap.properties**:这个文件定义了URI到worker的映射,决定了哪些URL请求会被发送到哪个Tomcat实例处理。 **本机8080.url、本机.url、c.com.url**:这些可能是书签文件,用于快速访问配置在不同端口或...
单tomcat 实例下 部署多应用程序实现。 实现简单,容易上手。。。
3. **WEB SERVICE部分**:这部分由`<Service>`标签表示,定义了Tomcat的服务实例,每个服务可以包含多个`<Connector>`(监听端口)和`<Engine>`(处理HTTP请求)。`<Connector>`配置了Tomcat监听的IP地址和端口,...
Tomcat运行配置代码实例,运行实例,更容易理解