tomcat 多实例,日志保留期限

1,tomcat多实例: 作为Windows服务进行管理


http://tomcat.apache.org/tomcat-8.0-doc/windows-service-howto.html

  • 1, 递归创建目录: apache-tomcat-8-muti-instance/instances/instance1
  • 2 , 解压tomcat: 把bin, lib 放到apache-tomcat-8-muti-instance目录里
  • 3,把conf放到apache-tomcat-8-muti-instance目录里,把conf/{server.xml, web.xml} 两个文件挑出来
  • 4,把其余目录放到instances/instance1里面,保持instance1里面的conf只有server.xml, web.xml
D:\software\apache-tomcat-8-muti-instance
λ ls
bin/  conf/  instances/  lib/ 

D:\software\apache-tomcat-8-muti-instance
λ ls instances\node_instance1
conf/  logs/  temp/  webapps/  work/

D:\software\apache-tomcat-8-muti-instance                                                                                                                                 
λ ls conf\   ##把server.xml , web.xml转移到instances/instance1,2,3里面                                                                                                                                           
Catalina/  catalina.policy  catalina.properties  context.xml  jaspic-providers.xml  jaspic-providers.xsd  logging.properties  tomcat-users.xml  tomcat-users.xsd          

D:\software\apache-tomcat-8-muti-instance
λ ls instances\node_instance1\conf\
Catalina/  server.xml  web.xml  
                                                                                                                                               
     
#### 设置变量: CATALINA_HOME是基本目录, 里面有多个instance: CATALINA_BASE
###############   安装实例1 ###############  
D:\software\apache-tomcat-8-muti-instance\bin     
λ set CATALINA_HOME=D:\software\apache-tomcat-8-muti-instance

D:\software\apache-tomcat-8-muti-instance\bin     
λ set CATALINA_BASE=D:\software\apache-tomcat-8-muti-instance\instances\node_instance1

D:\software\apache-tomcat-8-muti-instance\bin                                                                   
λ service.bat  install tomcat8_instance1                                                                        
Installing the service 'tomcat8_instance1' ...                                                                  
Using CATALINA_HOME:    "D:\software\apache-tomcat-8-muti-instance"                                             
Using CATALINA_BASE:    "D:\software\apache-tomcat-8-muti-instance\instances\node_instance1"                    
Using JAVA_HOME:        "D:\software\jdk1.8.0_3"                                                                
Using JRE_HOME:         "D:\software\jdk1.8.0_3\jre"                                                            
Using JVM:              "D:\software\jdk1.8.0_3\jre\bin\server\jvm.dll"                                         
The service 'tomcat8_instance1' has been installed.   

###############   安装实例2 ###############                                                         
D:\software\apache-tomcat-8-muti-instance\bin                                                                   
λ set CATALINA_BASE=D:\software\apache-tomcat-8-muti-instance\instances\node_instance2                          
                                                                                                                
D:\software\apache-tomcat-8-muti-instance\bin                                                                   
λ service.bat  install tomcat8_instance2                                                                        
Installing the service 'tomcat8_instance2' ...                                                                  
Using CATALINA_HOME:    "D:\software\apache-tomcat-8-muti-instance"                                             
Using CATALINA_BASE:    "D:\software\apache-tomcat-8-muti-instance\instances\node_instance2"                    
Using JAVA_HOME:        "D:\software\jdk1.8.0_3"                                                                
Using JRE_HOME:         "D:\software\jdk1.8.0_3\jre"                                                            
Using JVM:              "D:\software\jdk1.8.0_3\jre\bin\server\jvm.dll"                                         
The service 'tomcat8_instance2' has been installed.                                                                                                                                       

在这里插入图片描述

2,修改tomcat环境变量

  • catalina.bat/.sh文件说明
# windows 版: CATALINA_BASE/bin/setenv.bat
rem   Do not set the variables in this script. Instead put them into a script
rem   setenv.bat in CATALINA_BASE/bin to keep your customizations separate.
#
D:\software\apache-tomcat-8.5.54\bin
λ cat setenv.bat
set JAVA_OPTS=%JAVA_OPTS% ^
				-Xmx 2g -Xms 1g


# linux 版: CATALINA_BASE/bin/setenv.sh 
#   Do not set the variables in this script. Instead put them into a script
#   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
#
[root@test-c6 ~]# cat apache-tomcat-8.5.54/bin/setenv.sh
JAVA_OPTS="$JAVA_OPTS -Xmx2g -Xms1g"
CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"

3,tomcat日志保留期限

文档:http://tomcat.apache.org/tomcat-8.5-doc/logging.html#Access_logging

#修改server.xml: 添加属性参数 maxDays="1"
##localhost_access_log.2020-03-23.txt 保留期限  
[wang@c6 ~]# grep AccessLogValve  /opt/apache-tomcat-8.5.54/conf/server.xml -A 1
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" maxDays="1"
       prefix="localhost_access_log" suffix=".txt"

#修改logging.properties: 添加四行配置 maxDays="1"
#catalina.out   				maxDays=1
#localhost.2020-03-23.log 		maxDays=1
#host-manager.2021-02-04.log  	maxDays=1
[wang@c6 ~]# grep maxDays  /opt/apache-tomcat-8.5.54/conf/logging.properties
1catalina.org.apache.juli.AsyncFileHandler.maxDays=1
2localhost.org.apache.juli.AsyncFileHandler.maxDays=1
3manager.org.apache.juli.AsyncFileHandler.maxDays=1
4host-manager.org.apache.juli.AsyncFileHandler.maxDays=1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

根哥的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值