Tomcat - server.xml 配置文件

Summary

  • 8005 端口是用来关闭 tomcat 的端口,shutdown.sh 通过这个端口关闭当前正在运行的tomcat

Demo

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8905" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
    <GlobalNamingResources>
        <Resource name="UserDatabase"
                auth="Container"
                type="org.apache.catalina.UserDatabase"
                description="User database that can be updated and saved"
                factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                pathname="conf/tomcat-users.xml" />
    </GlobalNamingResources>
    <Service name="Catalina">
        <Executor name="tomcatThreadPool"
                namePrefix="catalina-exec1-"
                maxThreads="200"
                minSpareThreads="50"/>
        <Connector port="8980"
                protocol="HTTP/1.1"
                acceptCount="2000"
                maxConnections="2000"
                connectionTimeout="20000"
                executor="tomcatThreadPool"
                redirectPort="8443"
                disableUploadTimeout="true"
                URIEncoding="UTF-8"
                enableLookups="false"
                compression="on"
                compressionMinSize="1024"/>
        <Engine name="Catalina" defaultHost="localhost">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
            </Realm>

            <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                        directory="logs"
                        prefix="localhost_access_log"
                        suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
            </Host>
        </Engine>
    </Service>
</Server>

Executor

  • name:共享线程池的名字,必须唯一。
  • namePrefix:在JVM上,每个运行线程都可以有一个 name 字符串。这一属性为线程池中每个线程的name字符串设置了一个前缀,Tomcat将把线程号追加到这一前缀的后面。默认值:catalina-exec-;
  • maxThreads:该线程池可以容纳的最大线程数,默认值:150;
  • maxIdleTime:在Tomcat关闭一个空闲线程之前,允许空闲线程持续的时间(以毫秒为单位)。只有当前活跃的线程数大于minSpareThread的值,才会关闭空闲线程。默认值:60000(一分钟)。
  • minSpareThreads:Tomcat应该始终打开的最小不活跃线程数。默认值:4。
  • threadPriority:线程的等级,默认是Thread.NORM_PRIORITY

Connector

  • port: 端口号,提供 http|https 服务的端口号。
  • protocol:协议,
    • HTTP/1.1
    • org.apache.coyote.http11.Http11AprProtocol
  • executor:线程池
    • 指定所使用的线程池
  • acceptCount:指定当所有可以使用的处理请求的线程数都被使用时,可传入连接请求的最大队列长度,超过这个数的请求将不予处理,默认为100个。
posted @ 2020-07-27 15:57  duchaoqun  阅读(87)  评论(0编辑  收藏  举报