startup.sh 报错
Cannot find ./catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program
解决方法一:
在tomcat 的bin目录下 执行这条命令
chmod +x *.sh
方法二:
如果配置了环境变量,把命令前面的sh去掉,直接:startup.sh
tomcat Access 日志配置
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%a %l %u %t "%r" %s %b "%{Host}i" "%{Referer}i" "%{User-Agent}i" %h %A %D(ms)" />
设置 TOMCAT 请求超时时间 和 最大连接数
可以通过设置tomcat下conf文件夹的server.xml文件,对请求连接数和请求超时时间进行设置
// connectionTimeout以毫秒为单位,默认设置为20秒。通过修改该参数,可以修改tomcat的请求超时时间
<Connector port="8260" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
executor="tomcatThreadPool"
connectionTimeout="20000"
redirectPort="8261" acceptCount="500" maxThreads="400"/>
关于修改最大并发请求连接数,需要修改maxThreads和acceptCount两个参数
其中,maxThreads的介绍如下:
The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.
而acceptCount的介绍为:
The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.
所以两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads
Tomcat 配置GC
tomcat目录/bin
找到catalina.sh(这是linux下,window下应该是catalina.bat)
配置JAVA_OPTS参数,主要是红色部分。我这里配置的是tomcat目录/log目录下
JAVA_OPTS=’-Xms3300M -Xmx3300M -XX:PermSize=300m -XX:MaxPermSize=300m -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Xloggc:…/logs/tomcat_gc.log’