参数说明: * connectionTimeout - 网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。 * keepAliveTimeout - 长连接最大保持时间(毫秒)。此处为15秒。 * maxKeepAliveRequests - 最大长连接个数(1表示禁用,-1表示不限制个数,默认100个。一般设置在100~200之间) the maximum number of HTTP requests that can be held in the pipelineuntil the connection is closed by the server. Setting this attribute to1 disables HTTP/1.0 keep-alive, as well as HTTP/1.1 keep-alive and pipelining. Setting this to -1 allows an unlimited number of pipelined or keep-alive HTTP requests. If not specified,this attribute is set to 100. * maxHttpHeaderSize - http请求头信息的最大程度,超过此长度的部分不予处理。一般8K。 * URIEncoding - 指定Tomcat容器的URL编码格式。 * acceptCount - 指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理,默认为10个。defines the maximum queue length for incoming connection requestswhen all possible request processing threads are in use. Any requests received when the queue is full are refused. The default value is 10. * disableUploadTimeout - 上传时是否使用超时机制 * enableLookups - 是否反查域名,取值为:true或false。为了提高处理能力,应设置为false * bufferSize - definesthe>
* maxSpareThreads - 做多空闲连接数,一旦创建的线程超过这个值,Tomcat就会关闭不再需要的socket线程 the maximum number of unused request processing threads that are allowed to exist until the thread pool starts stopping the unnecessary threads. Thedefault value is 50. * maxThreads - 最多同时处理的连接数,Tomcat使用线程来处理接收的每个请求。这个值表示Tomcat可创建的最大的线程数。。the maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneousrequests that can be handled. If not specified, this attribute is set to 200. * minSpareThreads - 最小空闲线程数,Tomcat初始化时创建的线程数the number of request processing threads that are created when this Connector is first started. The connector will also make sure it has thespecified number of> 4、负载均衡、集群的配置 Tomcat6支持分布式部署,可以实现集群功能,提高响应能力。
5、利用JMX监控Tomcat运行情况,需要手工调整启动参数,如下: 打开cataline.bat,增加一行 set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=10090
-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" linux下修改cataline.sh: JAVA_OPTS="-Dcom.sun.management.jmxremote.port=10090-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=%CATALINA_BASE\conf\logging.properties" 注意JDK\jre\lib\management\management.properties文件必须存在。重新启动tomcat节点,然后用jconsole连接(此处端口wei10090)
6、Tomcat增加一个应用 在server.xml的Host标签中增加行 path代表上下文名称,空表示是根路径。 ================================= Tomcat6.x目录与server.xml详解 tomcat 服务器是一个免费的开放源代码的Web 应用服务器,目前最新版本是6.x,相对5.x性能提升很多,主要优化了内存使用,增强IO能力,重新构造集群功能。近期对Tomcat6.x作深入学习,参考上述声明的Tomcat全攻略,由于笔者是2001年针对Tomcat4.x所写,故参考之并针对 Tomcat6.x做了总结,形成此篇学习笔记,希望对学习的人有所帮助,本文涵盖了:Tomcat目录、Server.xml元素讲解,数据库连接池配置、线程池配置、虚拟目录配置。关于如何下载、安装、运行Tomcat略,请google,相信有详细的文章讲述。 tomcat的目录结构如下: 目录名 bin 存放启动和关闭tomcat脚本
conf 包含不同的配置文件,server.xml(Tomcat的主要配置文件)和web.xml work 存放jsp编译后产生的class文件webapp 存放应用程序示例,以后你要部署的应用程序也要放到此目录 logs 存放日志文件 lib 这三个目录主要存放tomcat所需的jar文件
server.xml配置简介
元素名
属性 解释 server port 指定一个端口,这个端口负责监听关闭tomcat的请求 shutdown
指定向端口发送的命令字符串 GlobalNamingResources
服务器的全局JNDI资源,可以有子标签 Executor(线程池,一个或多个Connector可以共享此线程池) name 线程池名称,名称必须唯一 namePrefix
线程的名字前缀,用来标记线程名字的,这样每个线程就用这个前缀加上线程编号了,比如 catalina-exec-1 、catalina-exec-2 maxThreads
允许的最大线程池里的线程数量,默认是200,大的并发应该设置的高一些,反正只是限制而已,不占用资源 minSpareThreads
最小的保持活跃的线程数量,默认是25.这个要根据负载情况自行调整了。太小了就影响反应速度,太大了白白占用资源 maxIdleTime
最小的保持活跃的线程数量,默认是25.这个要根据负载情况自行调整了。太小了就影响反应速度,太大了白白占用资源 threadPriority
线程的等级。默认是Thread.NORM_PRIORITY service name 指定service的名字 Connector (表示客户端和service之间的连接) port
指定服务器端要创建的端口号,并在这个断口监听来自客户端的请求 minProcessors 服务器启动时创建的处理请求的线程数 maxProcessors
最大可以创建的处理请求的线程数 enableLookups
如果为true,则可以通过调用request.getRemoteHost()进行DNS查询来得到远程客户端的实际主机名,若为false则不进行DNS查询,而是返回其ip地址 redirectPort
指定服务器正在处理http请求时收到了一个SSL传输请求后重定向的端口号 acceptCount
指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理 connectionTimeout
指定超时的时间数(以毫秒为单位) Engine (表示指定service中的请求处理机,接收和处理来自Connector的请求) name defaultHost
指定缺省的处理请求的主机名,它至少与其中的一个host元素的name属性值是一样的 jvmRoute host (表示一个虚拟主机、并且可以包含Context子节点配置虚拟目录)
name
指定主机名 appBase
应用程序基本目录,即存放应用程序的目录 unpackWARs
如果为true,则tomcat会自动将WAR文件解压,否则不解压,直接从WAR文件中运行应用程序 autoDeploy
自动部署 xmlValidation