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 安装步骤 ...
随机推荐
- 推荐近乎免费的调试神器——OzCode
当一只断点打在 Visual Studio 的代码编辑器中,程序命中断点的那一刻,调试才刚刚开始……这个时候忙碌的手在键盘和鼠标之间来回跳跃,试图抓住每一次单步执行带来的状态改变. 如果命中断点的那一 ...
- PHP的网站主要攻击方式有哪些
1.命令注入(Command Injection) 2.eval注入(Eval Injection) 3.客户端脚本攻击(Script Insertion) 4.跨网站脚本攻击(Cross Site ...
- css 常用类名
1.页面结构 容器: container 页头:header 内容:content/container 页面主体:main 页尾:footer 导航:nav 侧栏:sidebar 栏目:column ...
- curl 错误 [globbing] illegal character in range specification at pos
现象 在使用curl 进行ipv6请求的时候 curl -v "http://[1:1::1]/test.html" 发生了一个错误,报错是 [globbing] illegal ...
- hive加载json数据解决方案
hive官方并不支持json格式的数据加载,默认支持csv格式文件加载,如何在不依赖外部jar包的情况下实现json数据格式解析,本编博客着重介绍此问题解决方案 首先创建元数据表: create EX ...
- 6.Python使用Pandas小案例
1.使用以下命令引入Pandas和xlrd,引入成功后在pycharm的setting导入即可使用(pip3是由于个人python版本为3.6)==在dos命令行输入以下信息 pip3 install ...
- Hibernate Cannot release connection 了,有办法解决!
问题: 系统采用Spring MVC 2.5 + Spring 2.5 + Hibernate 3.2架构,其中数据源连接池采用的是Apache commons DBCP.问题是这样的,系统 ...
- 从wiresharp看tcp三次握手
我们知道,传输层是OSI模型中用户进行数据传输的分层,目前仅有TCP和UDP两种协议可用.TCP为了进行传输控制,引入了三次握手机制,以确保通信连接的建立.道理很简单,我们跟别人打电话聊天时,对方拿起 ...
- 回文字符串的变形——poj1159
回文字符串 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba".当然, ...
- golang调用动态库
测试动态库 test_so.h int test_so_func(int a,int b); test_so.c #include "test_so.h" int test_so_ ...