Tomcat ( 单机多 Tomcat 并存 )
简介:
Tomcat 扩展( 一台服务器运行多个 tomcat )
一、安装 JDK 、Tomcat
shell > rpm -ivh jdk-8u25-linux-x64.rpm # 安装 jdk ,jdk 版本最好与 tomcat 一致 shell > tar zxf apache-tomcat-8.0..tar.gz -C /usr/local/
shell > cd ..
shell > cp -r apache-tomcat-8.0. tomcat1 # 复制三份 tomcat 其中 tomcat1 保持不变
shell > cp -r apache-tomcat-8.0. tomcat2
shell > cp -r apache-tomcat-8.0. tomcat3
二、配置多 Tomcat
shell > vim tomcat2/conf/server.xml # 修改 tomcat2
<Server port="" shutdown="SHUTDOWN"> # 原端口为 修改为
<Connector port="" protocol="HTTP/1.1" # 原端口为 修改为
<Connector port="" protocol="AJP/1.3" redirectPort="" /> # 原端口为 修改为 shell > vim tomcat3/conf/server.xml # 修改 tomcat3
<Server port="" shutdown="SHUTDOWN"> # 原端口为 修改为
<Connector port="" protocol="HTTP/1.1" # 原端口为 修改为
<Connector port="" protocol="AJP/1.3" redirectPort="" /> # 原端口为 修改为
三、测试
shell > echo "welcome to tomcat1" > /usr/local/tomcat1/webapps/ROOT/index.html # 创建首面文件
shell > echo "welcome to tomcat2" > /usr/local/tomcat2/webapps/ROOT/index.html
shell > echo "welcome to tomcat3" > /usr/local/tomcat3/webapps/ROOT/index.html shell > /usr/local/tomcat1/bin/startup.sh # 启动 tomcat1
Using CATALINA_BASE: /usr/local/tomcat1
Using CATALINA_HOME: /usr/local/tomcat1
Using CATALINA_TMPDIR: /usr/local/tomcat1/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar
Tomcat started. shell > tail /usr/local/tomcat1/logs/catalina.out # 查看日志,这里有 tomcat 的开启、关闭信息
-Oct- ::29.296 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat1/webapps/manager has finished in ms
-Oct- ::29.301 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat1/webapps/examples
-Oct- ::30.488 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat1/webapps/examples has finished in , ms
-Oct- ::30.492 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat1/webapps/docs
-Oct- ::30.557 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat1/webapps/docs has finished in ms
-Oct- ::30.564 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat1/webapps/ROOT
-Oct- ::30.614 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat1/webapps/ROOT has finished in ms
-Oct- ::30.624 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
-Oct- ::30.643 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
-Oct- ::30.649 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in ms
# 可以看到服务启动花费的时间
shell > netstat -anpt | grep java # 监听的端口( 缺一不可 )
tcp ::: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::: :::* LISTEN /java shell > curl "http://192.168.1.80:8080" # 访问一下首页文件
welcome to tomcat1 shell > ps aux | grep java # 看看进程路径也没有问题
root 2.2 8.6 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat1/endorsed -classpath /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat1 -Dcatalina.home=/usr/local/tomcat1 -Djava.io.tmpdir=/usr/local/tomcat1/temp org.apache.catalina.startup.Bootstrap start shell > /usr/local/tomcat1/bin/shutdown.sh # 关闭 tomcat1
Using CATALINA_BASE: /usr/local/tomcat1
Using CATALINA_HOME: /usr/local/tomcat1
Using CATALINA_TMPDIR: /usr/local/tomcat1/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar
shell > /usr/local/tomcat1/bin/startup.sh # 启动 tomcat1
Using CATALINA_BASE: /usr/local/tomcat1
Using CATALINA_HOME: /usr/local/tomcat1
Using CATALINA_TMPDIR: /usr/local/tomcat1/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar
Tomcat started. shell > /usr/local/tomcat2/bin/startup.sh # 启动 tomcat2
Using CATALINA_BASE: /usr/local/tomcat2
Using CATALINA_HOME: /usr/local/tomcat2
Using CATALINA_TMPDIR: /usr/local/tomcat2/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar
Tomcat started. shell > /usr/local/tomcat3/bin/startup.sh # 启动 tomcat3
Using CATALINA_BASE: /usr/local/tomcat3
Using CATALINA_HOME: /usr/local/tomcat3
Using CATALINA_TMPDIR: /usr/local/tomcat3/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat3/bin/bootstrap.jar:/usr/local/tomcat3/bin/tomcat-juli.jar
Tomcat started.
shell > netstat -anpt | grep java # 这种情况是 tomcat 还没有完全启动,稍等即可
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java shell > tail /usr/local/tomcat3/logs/catalina.out # 日志中也没有出来服务启动成功的标志
-Oct- ::02.840 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
-Oct- ::03.619 INFO [main] org.apache.catalina.core.AprLifecycleListener.init The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
-Oct- ::04.374 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8082"]
-Oct- ::04.431 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
-Oct- ::04.442 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8029"]
-Oct- ::04.457 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
-Oct- ::04.461 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in ms
-Oct- ::04.597 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
-Oct- ::04.601 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.
-Oct- ::04.628 INFO [localhost-startStop-] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat3/webapps/host-manager
shell > netstat -anpt | grep java # 现在 tomcat1// 都已经全部启动
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::: :::* LISTEN /java shell > curl "http://192.168.1.80:8080" # 全部可以访问
welcome to tomcat1
shell > curl "http://192.168.1.80:8081"
welcome to tomcat2
shell > curl "http://192.168.1.80:8082"
welcome to tomcat3
shell > tail - /usr/local/tomcat1/logs/catalina.out # 可以看到启动时间有长有短
-Oct- ::11.536 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in ms shell > tail - /usr/local/tomcat2/logs/catalina.out
-Oct- ::30.971 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in ms shell > tail - /usr/local/tomcat3/logs/catalina.out
-Oct- ::10.965 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in ms shell > ps aux | grep java # 进程路径也都没有错
root 1.3 8.4 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat1/endorsed -classpath /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat1 -Dcatalina.home=/usr/local/tomcat1 -Djava.io.tmpdir=/usr/local/tomcat1/temp org.apache.catalina.startup.Bootstrap start
root 1.3 8.5 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat2/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat2/endorsed -classpath /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat2 -Dcatalina.home=/usr/local/tomcat2 -Djava.io.tmpdir=/usr/local/tomcat2/temp org.apache.catalina.startup.Bootstrap start
root 1.4 8.6 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat3/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat3/endorsed -classpath /usr/local/tomcat3/bin/bootstrap.jar:/usr/local/tomcat3/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat3 -Dcatalina.home=/usr/local/tomcat3 -Djava.io.tmpdir=/usr/local/tomcat3/temp org.apache.catalina.startup.Bootstrap start
shell > /usr/local/tomcat2/bin/shutdown.sh # 现在单独关闭任何一个 别的都不受影响
Using CATALINA_BASE: /usr/local/tomcat2
Using CATALINA_HOME: /usr/local/tomcat2
Using CATALINA_TMPDIR: /usr/local/tomcat2/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar shell > ps aux | grep java
root 1.2 8.4 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat1/endorsed -classpath /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat1 -Dcatalina.home=/usr/local/tomcat1 -Djava.io.tmpdir=/usr/local/tomcat1/temp org.apache.catalina.startup.Bootstrap start
root 1.2 8.6 pts/ Sl : : /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat3/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat3/endorsed -classpath /usr/local/tomcat3/bin/bootstrap.jar:/usr/local/tomcat3/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat3 -Dcatalina.home=/usr/local/tomcat3 -Djava.io.tmpdir=/usr/local/tomcat3/temp org.apache.catalina.startup.Bootstrap start
root 0.0 0.0 pts/ S+ : : grep java shell > netstat -anpt | grep java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::ffff:127.0.0.1: :::* LISTEN /java
tcp ::: :::* LISTEN /java
## 可以启动、关闭任意 tomcat ,没有顺序之分。唯一注意的一点,就是启动有一个过程,需要稍微等等,不要急。
只需修改端口即可,无需按照网上所说,要设置变量、更改 catalina.sh 等文件(如有不对的地方,还请各位指正)
Tomcat ( 单机多 Tomcat 并存 )的更多相关文章
- tomcat单机多实例部署
最近在面试的过程中,一家公司在面试时提到了有关tomcat单机多实例部署的提问, 正好, 之前使用IntelliJ IDEA 13.1.4这款IDE开发web项目,在开发的过程中,因为有多个web项目 ...
- 单机部署tomcat的shell脚本
单机部署tomcat的shell脚本,来自网络,自己需要时要根据自己的需求改动. #!/bin/sh # ############################################### ...
- 通过Zabbix监控Tomcat单机多实例
前面已经介绍过Tomcat单机多实例部署,接下来就在他的基础上进行下一步操作:Tomcat多实例监控! Tomcat多实例监控过程和之前的redis多实例原理一样,分为以下4步: 1.获取多实例 2. ...
- tomcat单机多实例
catalina.home指向公用信息的位置,就是bin和lib的父目录. catalina.base指向每个Tomcat目录私有信息的位置,就是conf.logs.temp.webapps和work ...
- 使用Maven自动部署Tomcat 6和Tomcat 7下Web应用
使用Maven自动部署Tomcat 6和Tomcat 7下Web应用 开启Tomcat远程管理权限 在tomcat的config目录下的tomcat-users.xml文件, <role rol ...
- 使用Apache + mod_jk + tomcat来实现tomcat集群的负载均衡出现的无法加载mod_jk.conf文件的问题
用Apache + mod_jk + tomcat来实现tomcat集群的负载均衡的 如果出现了问题,可以用cmd cd到Apache安装文件的bin下,运行httpd文件,错误信息就会打印出来. ...
- nginx代理tomcat后,tomcat获取真实(非proxy,非别名)nginx服务端ip端口的解决方案
nginx代理tomcat后,tomcat获取服务端ip端口的解决方案 1.注意修改nginx配置代理,标红地方 #user nginx; worker_processes ; error_log l ...
- Linux Tomcat安装,Linux配置Tomcat,Linux Tomcat修改内存,Linux tomcat修改端口
Linux Tomcat安装,Linux配置Tomcat,Linux Tomcat修改内存,Linux tomcat修改端口 >>>>>>>>>& ...
- CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤
准备文件如下: 1.CentOS-6.4-x86_64-bin-DVD1.iso 2.jdk-7u67-linux-x64.rpm 3.apache-tomcat-7.0.55.tar.gz 安装步骤 ...
随机推荐
- Codeforces 1030D 【构造】
LINK 题目大意:给你n,m,k,让你在一个n*m的点阵里构造出一个面积为\(\frac{n*m}{k}\)的三角形 思路 首先要有一个结论是整点三角形的面积分母最多为2,然后就可以判断不存在的情况 ...
- ajax 上传读取excel
$("#btnImport").click(function () { $("#File").click() })///委托 $("#File&quo ...
- 搭建jetbrains 注册服务器
wget http://home.ustc.edu.cn/~mmmwhy/jetbrain.sh && sh ./jetbrain.sh 输入默认的端口号跟用户名,然后记住服务器地址. ...
- flask第十九篇——模板【3】
请关注微信公众号:自动化测试实战 今天我们继续模板的知识,现在我们增加字典的复杂度,这个时候在render_template第二个参数可以传**title,以后我们会用**context代替原来的ti ...
- 实例-系数可配置的fir滤波器
- 【spring源码学习】spring集成orm数据框架
[一]简易的数据源配置 (1)配置文件 <!--springJdbcTemplemate数据操作配置信息 --> <bean id="driver" class= ...
- echarts tooltips宽度设置
提示文本太长显示不全,设置宽度后:
- lapis http verb 处理
1. 同一个url 包含不同的请求(respond_to 进行解决) // 路由格式 match ,通过respond_to 进行实际的http verb 处理 local lapis = requ ...
- 3.JMeter添加集合点
1.JMeter的集合点是通过添加定时器来完成的,在做性能测试时,真正的并发是不可能的,为了更真实的模拟并发场景,因此在需要压测的地方设置集合点,即可一起操作发送请求. 2.JMeter添加定时器,右 ...
- 老齐python-基础4(元祖、字典、集合)
1.元祖 元祖的特性结合了字符串和列表 元祖是用圆括号括起来的,其中的元素之间用逗号(英文半角)隔开.元祖中的元素是任意类型的python对象(包括以后自定义的对象) 元祖中的元素不可更改,所以修改列 ...