设为首页 收藏本站
查看: 438|回复: 0

[经验分享] Tomcat启动server.xml

[复制链接]

尚未签到

发表于 2017-1-24 06:52:50 | 显示全部楼层 |阅读模式
Tomcat Server的结构图


该文件描述了如何启动Tomcat Server

<Server>
<Listener />
<GlobaNamingResources>
</GlobaNamingResources
<Service>
<Connector />
<Engine>
<Logger />
<Realm />
<host>
<Logger />
<Context />
</host>
</Engine>
</Service>
</Server>

元素名


属性


解释

server

port

指定一个端口,这个端口负责监听关闭tomcat的请求
shutdown

指定向端口发送的命令字符串
service

name

指定service的名字
Connector(表示客户端和service之间的连接)

port

指定服务器端要创建的端口号,并在这个断口监听来自客户端的请求
minProcessors

服务器启动时创建的处理请求的线程数
maxProcessors

最大可以创建的处理请求的线程数
enableLookups

如果为true,则可以通过调用request.getRemoteHost()进行DNS查询来得到远程客户端的实际主机名,若为false则不进行DNS查询,而是返回其ip地址
redirectPort

指定服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号
acceptCount

指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理
connectionTimeout

指定超时的时间数(以毫秒为单位)
Engine(表示指定service中的请求处理机,接收和处理来自Connector的请求)

defaultHost

指定缺省的处理请求的主机名,它至少与其中的一个host元素的name属性值是一样的
Context(表示一个web应用程序,通常为WAR文件,关于WAR的具体信息见servlet规范)

docBase

应用程序的路径或者是WAR文件存放的路径
path

表示此web应用程序的url的前缀,这样请求的url为http://localhost:8080/path/****
reloadable

这个属性非常重要,如果为true,则tomcat会自动检测应用程序的/WEB-INF/lib 和/WEB-INF/classes目录的变化,自动装载新的应用程序,我们可以在不重起tomcat的情况下改变应用程序
host(表示一个虚拟主机)

name

指定主机名
appBase

应用程序基本目录,即存放应用程序的目录
unpackWARs

如果为true,则tomcat会自动将WAR文件解压,否则不解压,直接从WAR文件中运行应用程序
Logger(表示日志,调试和错误信息)

className

指定logger使用的类名,此类必须实现org.apache.catalina.Logger 接口
prefix

指定log文件的前缀
suffix

指定log文件的后缀
timestamp

如果为true,则log文件名中要加入时间,如下例:localhost_log.001-10-04.txt
Realm(表示存放用户名,密码及role的数据库)

className

指定Realm使用的类名,此类必须实现org.apache.catalina.Realm接口
Valve(功能与Logger差不多,其prefix和suffix属性解释和Logger 中的一样)

className

指定Valve使用的类名,如用org.apache.catalina.valves.AccessLogValve类可以记录应用程序的访问信息
directory

指定log文件存放的位置
pattern

有两个值,common方式记录远程主机名或ip地址,用户名,日期,第一行请求的字符串,HTTP响应代码,发送的字节数。combined方式比common方式记录的值更多
<Server>元素
它代表整个容器,是Tomcat实例的顶层元素.由org.apache.catalina.Server接口来定义.它包含一个<Service>元素.并且它不能做为任何元素的子元素.
<!-- 一个“Server”是一个提供完整的JVM的独立组件,它可以包含一个或多个
“Service”实例。服务器在指定的端口上监听shutdown命令。
注意:一个“Server”自身不是一个“Container”(容器),因此在这里你
不可以定义诸如“Valves”或者“Loggers”子组件
-->
<!-- 启动Server
在端口8005处等待关闭命令
如果接受到"SHUTDOWN"字符串则关闭服务器
-->

测试:
telnet localhost 8005   
输入:SHUTDOWN
结果:关闭tomcat
<Server port="8005" shutdown="SHUTDOWN" debug="0">
1>className指定实现org.apache.catalina.Server接口的类.默认值为org.apache.catalina.core.StandardServer
2>port指定Tomcat监听shutdown命令端口.终止服务器运行时,必须在Tomcat服务器所在的机器上发出shutdown命令.该属性是必须的.
3>shutdown指定终止Tomcat服务器运行时,发给Tomcat服务器的shutdown监听端口的字符串.该属性必须设置

<Service>元素
该元素由org.apache.catalina.Service接口定义,它包含一个<Engine>元素,以及一个或多个<Connector>,这些Connector元素共享用同一个Engine元素
<!-- 一个“Service”是一个或多个共用一个单独“Container”(容器)的“Connectors”
组合(因此,应用程序在容器中可见)。通常,这个容器是一个“Engine”
(引擎),但这不是必须的。
注意:一个“Service”自身不是一个容器,因此,在这个级别上你不可定义
诸如“Valves”或“Loggers”子组件。
-->
<!-- Tomcat的Standalone Service
Service是一组Connector的集合
它们共用一个Engine来处理所有Connector收到的请求
-->

<Service name="Catalina">
<Service name="Apache">
第一个<Service>处理所有直接由Tomcat服务器接收的web客户请求.
第二个<Service>处理所有由Apahce服务器转发过来的Web客户请求 .
1>className 指定实现org.apahce.catalina.Service接口的类.默认为org.apahce.catalina.core.StandardService
2>name定义Service的名字

<Connector>元素
由Connector接口定义.<Connector>元素代表与客户程序实际交互的给件,它负责接收客户请求,以及向客户返回响应结果.
<!-- 一个“Connector”(连接器)代表一个请求被接收和应答所需要的端点。每个连
接器通过相关的“Container”(容器)处理请求。
默认情况下,一个非SSL的HTTP/1.1的连接器被绑定在端口8080。你也可以通过
根据后面的使用说明并取消第二个连接器入口的注释,在端口8443上建立一个
SSL HTTP/1.1的连接器。开放SSL支持需要下面几步(参见Tomcat 5文档中怎样
配置SSL的说明以取得更多的详细信息):
* 如果你的JDK是1.3或1.3以前的版本,下载安装JSSE 1.0.2或以后版本,并放
置JAR文件到“$JAVA_HOME/jre/lib/ext”目录下。
* 带一个“changeit”的口令值执行:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (UNIX)
来生成它自己的证书私钥。
默认情况下,当一个web应用程序调用请求时,DNS查询是可行的。这将对性能造
成一些不利的影响,因此,你可以将“enableLookups”设置为“false”来关闭DNS
查询。当DNS查询被关闭时,request.getRemoteHost()将返回包含远程客户IP地
址的字符串。
-->

<!-- Coyote HTTP/1.1 Connector
className : 该Connector的实现类是org.apache.coyote.tomcat4.CoyoteConnector
port : 在端口号8080处侦听来自客户browser的HTTP1.1请求.如果把8080改成80,则只要输入 http://localhost/即可
protocol:设定Http协议,默认值为HTTP/1.1
minSpareThreads: 该Connector先创建5个线程等待客户请求,每个请求由一个线程负责
maxSpareThread:设定在监听端口的线程的最大数目,这个值也决定了服务器可以同时响应客户请求的最大数目.默认值为200
acceptCount : 当现有线程已经达到最大数75时,为客户请求排队.当队列中请求数超过100时,后来的请求返回Connection refused错误
redirectport : 当客户请求是https时,把该请求转发到端口8443去
enableLookups:如果设为true,表示支持域名解析,可以把IP地址解析为主机名.WEB应用中调用request.getRemoteHost方法返回客户机主机名.默认值为true
connectionTimeout:定义建立客户连接超时的时间.如果为-1,表示不限制建立客户连接的时间

其它属性略
-->

<Connector port="8080" maxThread="50" minSpareThreads="25" maxSpareThread="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />
<Connection port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" />
第一个Connector元素定义了一个HTTP Connector,它通过8080端口接收HTTP请求;第二个Connector元素定义了一个JD Connector,它通过8009端口接收由其它服务器转发过来的请求.

<Engine>元素
每个Service元素只能有一个Engine元素.处理在同一个<Service>中所有<Connector>元素接收到的客户请求.由org.apahce.catalina.Engine接口定义.
<!-- 一个“Engine”(引擎)代表处理每个请求的入口点(在Catalina内)。这个Tomcat
的标准独立引擎实现分析包含在请求中的HTTP头信息,并将请求传送到适当的主机
或虚拟主机上。-->

<!-- Engine用来处理Connector收到的Http请求
它将匹配请求和自己的虚拟主机,并把请求转交给对应的Host来处理
默认虚拟主机是localhost
-->

<Engine name="Catalina" defaultHost="localhost" debug="0">
1>className指定实现Engine接口的类,默认值为StandardEngine
2>defaultHost指定处理客户的默认主机名,在<Engine>中的<Host>子元素中必须定义这一主机
3>name定义Engine的名字
在<Engine>可以包含如下元素<Logger>, <Realm>, <Value>, <Host>

<Host>元素
它由Host接口定义.一个Engine元素可以包含多个<Host>元素.每个<Host>的元素定义了一个虚拟主机.它包含了一个或多个Web应用.
<!-- 定义默认的虚拟主机
注意:XML模式确认将不能与Xerces 2.2同工作。
-->

<!-- 虚拟主机localhost
appBase : 指定虚拟主机的目录,可以指定绝对目录,也可以指定相对于<CATALINA_HOME>的相对目录.如果没有此项,默认为<CATALINA_HOME>/webapps. 它将匹配请求和自己的Context的路径,并把请求转交给对应的Context来处理
autoDeploy:如果此项设为true,表示Tomcat服务处于运行状态时,能够监测appBase下的文件,如果有新有web应用加入进来,会自运发布这个WEB应用
unpackWARs:如果此项设置为true,表示把WEB应用的WAR文件先展开为开放目录结构后再运行.如果设为false将直接运行为WAR文件
alias:指定主机别名,可以指定多个别名
deployOnStartup:如果此项设为true,表示Tomcat服务器启动时会自动发布appBase目录下所有的Web应用.如果Web应用中的server.xml没有相应的<Context>元素,将采用Tomcat默认的Context


-->

<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
在<Host>元素中可以包含如下子元素
<Logger>, <Realm>, <Value>, <Context>

<Context>元素
它由Context接口定义.是使用最频繁的元素.每个<Context元素代表了运行在虚拟主机上的单个Web应用.一个<Host>可以包含多个<Context>元素.每个web应用有唯一
的一个相对应的Context代表web应用自身.servlet容器为第一个web应用创建一个
<!-- Context,对应于一个Web App
path : 该Context的路径名是"",故该Context是该Host的默认Context
docBase : 该Context的根目录是webapps/mycontext/
reloadable:如果这个属性设为true, Tomcat服务器在运行状态下会监视在WEB-INF/classes和Web-INF/lib目录CLASS文件的改运.如果监视到有class文件被更新,服务器自重新加载Web应用
useNaming:指定是否支持JNDI,默认值为了true
cookies指定是否通过Cookies来支持Session,默认值为true
-->
<Context path="" docBase="mycontext" debug="0"/>

Tomcat Server处理一个http请求的过程
假设来自客户的请求为:
http://localhost:8080/wsota/wsota_index.jsp
1) 请求被发送到本机端口8080,被在那里侦听的Coyote HTTP/1.1 Connector获得
2) Connector把该请求交给它所在的Service的Engine来处理,并等待来自Engine的回应
3) Engine获得请求localhost/wsota/wsota_index.jsp,匹配它所拥有的所有虚拟主机Host
4) Engine匹配到名为localhost的Host(即使匹配不到也把请求交给该Host处理,因为该Host被定义为该Engine的默认主机)
5) localhost Host获得请求/wsota/wsota_index.jsp,匹配它所拥有的所有Context
6) Host匹配到路径为/wsota的Context(如果匹配不到就把该请求交给路径名为""的Context去处理)
7) path="/wsota"的Context获得请求/wsota_index.jsp,在它的mapping table中寻找对应的servlet
8) Context匹配到URL PATTERN为*.jsp的servlet,对应于JspServlet类
9) 构造HttpServletRequest对象和HttpServletResponse对象,作为参数调用JspServlet的doGet或doPost方法
10)Context把执行完了之后的HttpServletResponse对象返回给Host
11)Host把HttpServletResponse对象返回给Engine
12)Engine把HttpServletResponse对象返回给Connector
13)Connector把HttpServletResponse对象返回给客户browser
- <!--  Example Server Configuration File
-->
- <!--
Note that component elements are nested corresponding to their
parent-child relationships with each other
-->
- <!--
A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances.  The Server
listens for a shutdown command on the indicated port.
Note:  A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.

-->
- <Server port="7030" shutdown="SHUTDOWN">
+ <!--  Comment these entries out to disable JMX MBeans support used for the
administration web application
-->
<Listener className="org.apache.catalina.core.AprLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener" />
- <!--  Global JNDI resources
-->
+ <GlobalNamingResources>
- <!--  Test entry for demonstration purposes
-->
<Environment name="simpleValue" type="java.lang.Integer" value="30" />
- <!--
Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<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>
+ <!--  A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container).  Normally, that Container is an "Engine",
but this is not required.
Note:  A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
- <!--  Define the Tomcat Stand-Alone Service
-->
- <Service name="Catalina">
+ <!--  A "Connector" represents an endpoint by which requests are received
and responses are returned.  Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry.  SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 5 documentation bundle for more detailed
instructions):
* If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost().  This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false".  When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
- <!--  Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8030" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" />
+ <!--  Note : To disable connection timeouts, set connectionTimeout value
to 0
-->
+ <!--  Note : To use gzip compression you could set the following properties :
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
- <!--  Define a SSL HTTP/1.1 Connector on port 8443
-->
+ <!--     <Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
- <!--  Define an AJP 1.3 Connector on port 8009
-->
<Connector port="9030" URIEncoding="UTF-8" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
- <!--  Define a Proxied HTTP/1.1 Connector on port 8082
-->
- <!--  See proxy documentation for more information about using this.
-->
+ <!--     <Connector port="8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" acceptCount="100" connectionTimeout="20000"
proxyPort="80" disableUploadTimeout="true" />
-->
+ <!--  An Engine represents the entry point (within Catalina) that processes
every request.  The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
-->
+ <!--  You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
-->
- <!--  Define the top level container in our container hierarchy
-->
- <Engine name="Catalina" defaultHost="localhost">
+ <!--  The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat.  If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.4
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default.  Uncomment the following
element to enable it.
-->
+ <!--       <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
- <!--  Because this Realm is here, an instance will be shared globally
-->
+ <!--  This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase".  Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm.  
-->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
+ <!--  Comment out the old realm but leave here for now in case we
need to go back quickly
-->
+ <!--       <Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
+ <!--  Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC
-->
+ <!--       <Realm  className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
+ <!--       <Realm  className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
+ <!--       <Realm  className="org.apache.catalina.realm.JDBCRealm"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
+ <!--  Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
- <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
+ <!--  Defines a cluster for this node,
By defining this element, means that every manager will be changed.
So when running a cluster, only make sure that you have webapps in there
that need to be clustered and remove the other ones.
A cluster has the following parameters:
className = the fully qualified name of the cluster class
name = a descriptive name for your cluster, can be anything
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
mcastBindAddr = bind the multicast socket to a specific address
mcastTTL = the multicast TTL if you want to limit your broadcast
mcastSoTimeout = the multicast readtimeout
mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards.
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
<%
HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information.
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless there is a
large network delay.
-->
+ <!--             When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
The deployer element can be used to deploy apps cluster wide.
Currently the deployment only deploys/undeploys to working members in the cluster
so no WARs are copied upons startup of a broken node.
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
-->
+ <!--         <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
</Cluster>
-->
+ <!--  Normally, users must authenticate themselves to each web app
individually.  Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across *all* web applications contained
in this virtual host.
-->
+ <!--         <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
+ <!--  Access log processes all requests for this virtual host.  By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME.  If you wish, you can specify a different
directory with the "directory" attribute.  Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
+ <!--         <Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"  prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
+ <!--  Access log processes all requests for this virtual host.  By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME.  If you wish, you can specify a different
directory with the "directory" attribute.  Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
-->
+ <!--         <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs"  prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
+ <!--  Access log processes all requests for this virtual host.  By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME.  If you wish, you can specify a different
directory with the "directory" attribute.  Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
This valve use NIO direct Byte Buffer to asynchornously store the
log.
-->
+ <!--         <Valve className="org.apache.catalina.valves.ByteBufferAccessLogValve"
directory="logs"  prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
</Host>
</Engine>
</Service>
</Server>
1. <Server port="8005" shutdown="SHUTDOWN">  
2. <!--属性说明  
3.     port:指定一个端口,这个端口负责监听关闭Tomcat的请求  
4.     shutdown:向以上端口发送的关闭服务器的命令字符串  
5. -->  
6.   <Listener className="org.apache.catalina.core.AprLifecycleListener" />  
7.   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />  
8.   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />  
9.   <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>  
10.   
11.   <GlobalNamingResources>  
12.   
13.     <Environment name="simpleValue" type="java.lang.Integer" value="30"/>  
14.   
15.     <Resource name="UserDatabase" auth="Container"  
16.               type="org.apache.catalina.UserDatabase"  
17.        description="User database that can be updated and saved"  
18.            factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  
19.           pathname="conf/tomcat-users.xml" />  
20.   
21.   </GlobalNamingResources>  
22. <!--
23.     每个Service元素只能有一个Engine元素.元素处理在同一个<Service>中所有<Connector>元素接收到的客户请求
24. -->  
25.   <Service name="Catalina">  
26. <!--属性说明  
27.     name:Service的名称  
28. -->  
29.   
30.   
31.   
32.     <!--  
33.     Connector元素:由Connector接口定义.<Connector>元素代表与客户程序实际交互的给件,  
34.                   它负责接收客户请求,以及向客户返回响应结果.  
35.     -->  
36.     <Connector port="80" maxHttpHeaderSize="8192"  
37.                maxThreads="150" minSpareThreads="25" maxSpareThreads="75"  
38.                enableLookups="false" redirectPort="8443" acceptCount="100"  
39.                connectionTimeout="20000" disableUploadTimeout="true" />  
40.     <!--属性说明  
41.     port:服务器连接器的端口号,该连接器将在指定端口侦听来自客户端的请求  
42.     enableLookups:如果为true,则可以通过调用request.getRemoteHost()进行DNS查询来得到远程客户端  
43.                       的实际主机名;若为false则不进行DNS查询,而是返回其ip地址  
44.     redirectPort:服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号  
45.     acceptCount:当所有可以使用的处理请求的线程都被用光时,可以放到处理队列中的请求数,超过这个数  
46.                     的请求将不予处理,而返回Connection refused错误  
47.         connectionTimeout:等待超时的时间数(以毫秒为单位)  
48.     maxThreads:设定在监听端口的线程的最大数目,这个值也决定了服务器可以同时响应客户请求的最大数目.默认值为200  
49.         protocol:必须设定为AJP/1.3协议.  
50.         address:如果服务器有两个以上IP地址,该属性可以设定端口监听的IP地址,默认情况下,端口会监听服务器上所有IP地址.  
51.     minProcessors:服务器启动时创建的处理请求的线程数,每个请求由一个线程负责  
52.     maxProcessors:最多可以创建的处理请求的线程数  
53.     minSpareThreads:最小备用线程   
54.         maxSpareThreads:最大备用线程  
55.     debug:日志等级  
56.     disableUploadTimeout:禁用上传超时,主要用于大数据上传时  
57.     -->  
58.   
59.   
60.     <Connector port="8009"   
61.                enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />  
62.   
63.      
64.     <Engine name="Catalina" defaultHost="localhost">  
65.     <!--属性说明  
66.     name:对应$CATALINA_HOME/config/Catalina中的Catalina   
67.         defaultHost:对应Host元素中的name属性,也就是和$CATALINA_HOME/config/Catalina/localhost中的localhost  
68.             缺省的处理请求的虚拟主机名,它至少与其中的一个Host元素的name属性值是一样的  
69.         debug:日志等级  
70.     -->  
71.   
72.       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
73.              resourceName="UserDatabase"/>  
74.     <!--  
75.     由Host接口定义.一个Engine元素可以包含多个<Host>元素.  
76.         每个<Host>的元素定义了一个虚拟主机.它包含了一个或多个Web应用.  
77.     -->  
78.       <Host name="localhost" appBase="webapps"  
79.        unpackWARs="true" autoDeploy="true"  
80.        xmlValidation="false" xmlNamespaceAware="false">  
81.     <!--属性说明  
82.     name:在此例中一直被强调为$CATALINA_HOME/config/Catalina/localhost中的localhost  
83.          虚拟主机名  
84.         debug:是日志的调试等级   
85.         appBase: 默认的应用路径,也就是把应用放在一个目录下,并在autoDeploy为true的情况下,可自动部署应用此路径相对于                   $CATALINA_HOME/ (web applications的基本目录)  
86.         unpackWARs:设置为true,在Web应用为*.war是,解压此WAR文件.   
87.                如果为true,则tomcat会自动将WAR文件解压;否则不解压,直接从WAR文件中运行应用程序.  
88.         autoDeploy:默认为true,表示如果有新的WEB应用放入appBase 并且Tomcat在运行的情况下,自动载入应用   
89.     -->  
90.   
91.     <Context path="/demm" docBase="E:\\projects\\demm\\WebRoot" debug="0" reloadable="true" >   
92.         </Context>  
93.     <!--属性说明  
94.     path:访问的URI,如:http://localhost/是我的应用的根目录,访问此应用将用:http://localhost/demm进行操作,此元素必须.   
95.         表示此web application的URL的前缀,用来匹配一个Context。请求的URL形式为http://localhost:8080/path/*  
96.         docBase:WEB应用的目录,此目录必须符号Java WEB应用的规范.   
97.              web application的文件存放路径或者是WAR文件存放路径  
98.         debug:日志等级   
99.         reloadable:是否在程序有改动时重新载入,设置成true会影响性能,但可自动载入修改后的文件.  
100.            如果为true,则Tomcat将支持热部署,会自动检测web application的/WEB-INF/lib   
101.                    和/WEB-INF/classes目录的变化,自动装载新的JSP和Servlet,我们可以在不重起  
102.                    Tomcat的情况下改变web application  
103.     -->  
104.       </Host>  
105.   
106.     </Engine>  
107.   
108.   </Service>  
109.   
110. </Server>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-332542-1-1.html 上篇帖子: tomcat web.xml配置(转) 下篇帖子: Eclipse下Maven+tomcat配置(1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表