服务器

位置:IT落伍者 >> 服务器 >> 浏览文章

实现在tomcat中跑多个服务器实例


发布日期:2022年11月22日
 
实现在tomcat中跑多个服务器实例

Serverxml 注释

Server

Server只能有一个它代表整个JVMserver可以包含一个或者多个service

Service

service包含一个或者多个connector和container

Conector:

connector用来为container接收请求和返回响应的

Engine

engine是顶层container它可以包含一个或者多个host

Host

host是虚拟主机它可以包含一个或者多个context

Context

context对应一个web application

最近抽时间研究了一下tomcat的源码发现可以增加多个Service到serverxml中实现在tomcat中跑多个服务器实例在Serverxml中增加如下配置信息

Xml代码

<Service name=Catalina>

<Connector port=

maxThreads= minSpareThreads= maxSpareThreads=

enableLookups=false redirectPort= acceptCount=

debug= connectionTimeout=

disableUploadTimeout=true />

<Connector port=

enableLookups=false redirectPort= debug=

protocol=AJP/ />

<Engine name=Catalina defaultHost=localhost debug=>

<Logger className=orgapachecatalinaloggerFileLogger

prefix=catalina_log suffix=txt

timestamp=true/>

<Realm className=orgapachecatalinarealmUserDatabaseRealm

debug= resourceName=UserDatabase/>

<Host name=localhost debug= appBase=webapps

unpackWARs=true autoDeploy=true

xmlValidation=false xmlNamespaceAware=false>

<Logger className=orgapachecatalinaloggerFileLogger

directory=logs prefix=localhost_log suffix=txt

timestamp=true/>

</Host>

</Engine>

</Service>

上一篇:Apache FileUpload文件上传组件API解析

下一篇:Java 文件分块上传服务器端源代码