windows下tomcat集群配置(两种方法)
两种方法只是在配置上不同原理一样,因为apache2.X后其自身集成了mod_jk功能,相对于1.3版本,不需要再进行繁琐的worker.properties配置,配置过程大幅简化。
一、软件需求
操作系统:Windows XP
JDK:jdk1.6.0_16,下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 。
Apache :httpd-2.2.17 (一个),下载地址:http://httpd.apache.org/ 。
Tomcat:tomcat-7.0.2 (两个),下载地址:http://tomcat.apache.org/download-70.cgi 。
mod_jk:mod_jk-apache-2.0.55.so (1个),下载地址:http://tomcat.apache.org/download-70.cgi 。
二、环境搭建
安照上篇《windows下apache tomcat整合》中的方法安装jdk/apache/tomcat
三、环境配置(两种配置)
1. 原始配置
(1)apache配置
1>mod_jk.conf(apache/conf)
1 # 加载mod_jk模块,此处的mod_jk.so为你复制到modules/下的mod_jk名2 LoadModule jk_module modules/mod_jk-apache-2.2.2.so3 # 指定 workers.properties文件路径(指定tomcat监听配置文件地址4 JkWorkersFile conf/workers.properties5 # 设置日志存放路径6 JkLogFile logs/mod_jk.log7 # 设置日志级别 [debug/error/info] 8 JkLogLevel info9 # 设置日志格式10 JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 11 # JkOptions indicate to send SSL KEY SIZE, 12 JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories13 # JkRequestLogFormat set the request format14 JkRequestLogFormat "%w %V %T" 15 16 #设置虚拟主机17 #<VirtualHost localhost>18 #如果非虚拟主机,将<VirtualHost localhost>和最后的</VirtualHost>注释或者删除掉即可19 #ServerAdmin localhost20 #DocumentRoot E:/wwwroot21 #<Directory "E:/wwwroot">22 #您的站点项目所在路径,应与tomcat中的目录设置相同,据说以上两个必须同时设置才可以生效,没有试过不同的时候会有什么情况23 #ServerName localhost24 #DirectoryIndex index.html index.htm index.jsp25 #ErrorLog logs/shsc-error_log.txt26 #CustomLog logs/shsc-access_log.txt common27 #JkMount /servlet/* ajp1328 #让Apache支持对servlet传送,用以Tomcat解析29 #JkMount /*.jsp ajp1330 #让Apache支持对jsp传送,用以Tomcat解析31 #JkMount /*.do ajp1332 #让Apache支持对.do传送,用以Tomcat解析33 #</VirtualHost>34 35 #Send servlet for context /examples to worker named #ajp13,指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器(让Apache支持对jsp传送,用以Tomcat解析)36 JkMount /*.jsp controller37 JkMount /*.do controller38 JkMount /*.dd controller39 JkMount /*.ee controller40 JkMount /servlet/* controller41 JkMount /gwyhr* controller
2>httpd.conf(apache/conf)
1 #2 # This is the main Apache HTTP server configuration file. It contains the3 # configuration directives that give the server its instructions.4 # See <URL:http://httpd.apache.org/docs/2.2> for detailed information.5 # In particular,see6 # <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>7 # for a discussion of each configuration directive.8 #9 # Do NOT simply read the instructions in here without understanding10 # what they do. They're here only as hints or reminders. If you are unsure11 # consult the online docs. You have been warned.12 #13 # Configuration and logfile names: If the filenames you specify for many14 # of the server's control files begin with "/" (or "drive:/" for Win32),the15 # server will use that explicit path. If the filenames do *not* begin16 # with "/", the value of ServerRoot is prepended -- so "logs/foo.log" 17 # with ServerRoot set to "D:/Program Files/Apache Software Foundation/Apache2.2"will be interpreted by the18 # server as "D:/Program Files/Apache Software Foundation/Apache2.2/logs/foo.log".19 #20 # NOTE: Where filenames are specified,you must use forward slashes21 # instead of backslashes (e.g., "c:/apache" instead of "c:\apache").22 # If a drive letter is omitted,the drive on which httpd.exe is located23 # will be used by default. It is recommended that you always supply24 # an explicit drive letter in absolute paths to avoid confusion.25 26 #27 # ServerRoot: The top of the directory tree under which the server's28 # configuration, error,and log files are kept.29 #30 # Do not add a slash at the end of the directory path. If you point31 # ServerRoot at a non-local disk,be sure to point the LockFile directive32 # at a local disk. If you wish to share the same ServerRoot for multiple33 # httpd daemons,you will need to change at least LockFile and PidFile.34 #35 ServerRoot "D:/Program Files/Apache Software Foundation/Apache2.2" 36 37 #38 # Listen: Allows you to bind Apache to specific IP addresses and/or39 # ports,instead of the default. See also the <VirtualHost>40 # directive.41 #42 # Change this to Listen on specific IP addresses as shown below to43 # prevent Apache from glomming onto all bound IP addresses.44 #45 #Listen 12.34.56.78:80 46 Listen 80 47 48 #49 # Dynamic Shared Object (DSO) Support50 #51 # To be able to use the functionality of a module which was built as a DSO you52 # have to place corresponding `LoadModule' lines at this location so the53 # directives contained in it are actually available _before_ they are used.54 # Statically compiled modules (those listed by `httpd -l') do not need55 # to be loaded here.56 #57 # Example:58 # LoadModule foo_module modules/mod_foo.so59 #60 LoadModule actions_module modules/mod_actions.so61 LoadModule alias_module modules/mod_alias.so62 LoadModule asis_module modules/mod_asis.so63 LoadModule auth_basic_module modules/mod_auth_basic.so64 #LoadModule auth_digest_module modules/mod_auth_digest.so65 #LoadModule authn_alias_module modules/mod_authn_alias.so66 #LoadModule authn_anon_module modules/mod_authn_anon.so67 #LoadModule authn_dbd_module modules/mod_authn_dbd.so68 #LoadModule authn_dbm_module modules/mod_authn_dbm.so69 LoadModule authn_default_module modules/mod_authn_default.so70 LoadModule authn_file_module modules/mod_authn_file.so71 #LoadModule authnz_ldap_module modules/mod_authnz_ldap.so72 #LoadModule authz_dbm_module modules/mod_authz_dbm.so73 LoadModule authz_default_module modules/mod_authz_default.so74 LoadModule authz_groupfile_module modules/mod_authz_groupfile.so75 LoadModule authz_host_module modules/mod_authz_host.so76 #LoadModule authz_owner_module modules/mod_authz_owner.so77 LoadModule authz_user_module modules/mod_authz_user.so78 LoadModule autoindex_module modules/mod_autoindex.so79 #LoadModule cache_module modules/mod_cache.so80 #LoadModule cern_meta_module modules/mod_cern_meta.so81 LoadModule cgi_module modules/mod_cgi.so82 #LoadModule charset_lite_module modules/mod_charset_lite.so83 #LoadModule dav_module modules/mod_dav.so84 #LoadModule dav_fs_module modules/mod_dav_fs.so85 #LoadModule dav_lock_module modules/mod_dav_lock.so86 #LoadModule dbd_module modules/mod_dbd.so87 88 ######apache启用gzip压缩######89 #加载mod_deflate.so模块90 LoadModule deflate_module modules/mod_deflate.so91 #对text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript启用GZIP压缩92 AddOutputFilterByType DEFLATE text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript93 #压缩级别 9性能最佳94 DeflateCompressionLevel 9 95 #启用deflate模块对本站点的所有输出进行GZIP压缩96 SetOutputFilter DEFLATE97 #############################98 99 LoadModule dir_module modules/mod_dir.so100 #LoadModule disk_cache_module modules/mod_disk_cache.so101 #LoadModule dumpio_module modules/mod_dumpio.so102 LoadModule env_module modules/mod_env.so103 #LoadModule expires_module modules/mod_expires.so104 #LoadModule ext_filter_module modules/mod_ext_filter.so105 #LoadModule file_cache_module modules/mod_file_cache.so106 #LoadModule filter_module modules/mod_filter.so107 #LoadModule headers_module modules/mod_headers.so108 #LoadModule ident_module modules/mod_ident.so109 #LoadModule imagemap_module modules/mod_imagemap.so110 LoadModule include_module modules/mod_include.so111 #LoadModule info_module modules/mod_info.so112 LoadModule isapi_module modules/mod_isapi.so113 #LoadModule ldap_module modules/mod_ldap.so114 #LoadModule logio_module modules/mod_logio.so115 LoadModule log_config_module modules/mod_log_config.so116 #LoadModule log_forensic_module modules/mod_log_forensic.so117 #LoadModule mem_cache_module modules/mod_mem_cache.so118 LoadModule mime_module modules/mod_mime.so119 #LoadModule mime_magic_module modules/mod_mime_magic.so120 LoadModule negotiation_module modules/mod_negotiation.so121 #LoadModule proxy_module modules/mod_proxy.so122 #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so123 #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so124 #LoadModule proxy_connect_module modules/mod_proxy_connect.so125 #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so126 #LoadModule proxy_http_module modules/mod_proxy_http.so127 #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so128 #LoadModule reqtimeout_module modules/mod_reqtimeout.so129 #LoadModule rewrite_module modules/mod_rewrite.so130 LoadModule setenvif_module modules/mod_setenvif.so131 #LoadModule speling_module modules/mod_speling.so132 #LoadModule ssl_module modules/mod_ssl.so133 #LoadModule status_module modules/mod_status.so134 #LoadModule substitute_module modules/mod_substitute.so135 #LoadModule unique_id_module modules/mod_unique_id.so136 #LoadModule userdir_module modules/mod_userdir.so137 #LoadModule usertrack_module modules/mod_usertrack.so138 #LoadModule version_module modules/mod_version.so139 #LoadModule vhost_alias_module modules/mod_vhost_alias.so140 141 <IfModule !mpm_netware_module>142 <IfModule !mpm_winnt_module>143 #144 # If you wish httpd to run as a different user or group,you must run145 # httpd as root initially and it will switch.146 #147 # User/Group: The name (or #number) of the user/group to run httpd as.148 # It is usually good practice to create a dedicated user and group for149 # running httpd,as with most system services.150 #151 User daemon152 Group daemon153 154 </IfModule>155 </IfModule>156 157 # 'Main' server configuration158 #159 # The directives in this section set up the values used by the 'main'160 # server,which responds to any requests that aren't handled by a161 # <VirtualHost> definition. These values also provide defaults for162 # any <VirtualHost> containers you may define later in the file.163 #164 # All of these directives may appear inside <VirtualHost> containers, 165 # in which case these default settings will be overridden for the166 # virtual host being defined.167 #168 169 #170 # ServerAdmin: Your address,where problems with the server should be171 # e-mailed. This address appears on some server-generated pages,such172 # as error documents. e.g. admin@your-domain.com173 #174 ServerAdmin zbjbox@gmail.com175 176 #177 # ServerName gives the name and port that the server uses to identify itself.178 # This can often be determined automatically,but we recommend you specify179 # it explicitly to prevent problems during startup.180 #181 # If your host doesn't have a registered DNS name,enter its IP address here.182 #183 #ServerName localhost:80 184 185 #186 # DocumentRoot: The directory out of which you will serve your187 # documents. By default, all requests are taken from this directory,but188 # symbolic links and aliases may be used to point to other locations.189 #190 DocumentRoot "D:/Program Files/Apache Software Foundation/Apache2.2/htdocs" 191 192 #193 # Each directory to which Apache has access can be configured with respect194 # to which services and features are allowed and/or disabled in that195 # directory (and its subdirectories).196 #197 # First, we configure the "default"to be a very restrictive set of198 # features.199 #200 <Directory />201 Options FollowSymLinks202 AllowOverride None203 Order deny,allow204 Deny from all205 </Directory>206 207 #208 # Note that from this point forward you must specifically allow209 # particular features to be enabled - so if something's not working as210 # you might expect,make sure that you have specifically enabled it211 # below.212 #213 214 #215 # This should be changed to whatever you set DocumentRoot to.216 #217 <Directory "D:/Program Files/Apache Software Foundation/Apache2.2/htdocs">218 #219 # Possible values for the Options directive are "None", "All", 220 # or any combination of:221 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews222 #223 # Note that "MultiViews" must be named *explicitly* --- "Options All" 224 # doesn't give it to you.225 #226 # The Options directive is both complicated and important. Please see227 # http://httpd.apache.org/docs/2.2/mod/core.html#options228 # for more information.229 #230 Options Indexes FollowSymLinks231 232 #233 # AllowOverride controls what directives may be placed in .htaccess files.234 # It can be "All", "None",or any combination of the keywords:235 # Options FileInfo AuthConfig Limit236 #237 AllowOverride None238 239 #240 # Controls who can get stuff from this server.241 #242 Order allow,deny243 Allow from all244 245 </Directory>246 247 #248 # DirectoryIndex: sets the file that Apache will serve if a directory249 # is requested.250 # 此处加上index.jsp是为了配置完tomcat后若apache中的index.html不存在则能看到tomcat的首页(可以不加,则看到的是it works)251 #252 <IfModule dir_module>253 DirectoryIndex index.html index.jsp254 </IfModule>255 256 #257 # The following lines prevent .htaccess and .htpasswd files from being258 # viewed by Web clients.259 #260 <FilesMatch "^\.ht">261 Order allow,deny262 Deny from all263 Satisfy All264 </FilesMatch>265 266 #267 # ErrorLog: The location of the error log file.268 # If you do not specify an ErrorLog directive within a <VirtualHost>269 # container,error messages relating to that virtual host will be270 # logged here. If you *do* define an error logfile for a <VirtualHost>271 # container,that host's errors will be logged there and not here.272 #273 ErrorLog "logs/error.log" 274 275 #276 # LogLevel: Control the number of messages logged to the error_log.277 # Possible values include: debug, info, notice, warn, error, crit, 278 # alert,emerg.279 #280 LogLevel warn281 282 <IfModule log_config_module>283 #284 # The following directives define some format nicknames for use with285 # a CustomLog directive (see below).286 #287 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""combined288 LogFormat "%h %l %u %t \"%r\" %>s %b"common289 290 <IfModule logio_module>291 # You need to enable mod_logio.c to use %I and %O292 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"combinedio293 </IfModule>294 295 #296 # The location and format of the access logfile (Common Logfile Format).297 # If you do not define any access logfiles within a <VirtualHost>298 # container, they will be logged here. Contrariwise,if you *do*299 # define per-<VirtualHost> access logfiles,transactions will be300 # logged therein and *not* in this file.301 #302 CustomLog "logs/access.log"common303 304 #305 # If you prefer a logfile with access, agent,and referer information306 # (Combined Logfile Format) you can use the following directive.307 #308 #CustomLog "logs/access.log"combined309 </IfModule>310 311 <IfModule alias_module>312 #313 # Redirect: Allows you to tell clients about documents that used to314 # exist in your server's namespace,but do not anymore. The client315 # will make a new request for the document at its new location.316 # Example:317 # Redirect permanent /foo http://localhost/bar318 319 #320 # Alias: Maps web paths into filesystem paths and is used to321 # access content that does not live under the DocumentRoot.322 # Example:323 # Alias /webpath /full/filesystem/path324 #325 # If you include a trailing / on /webpath then the server will326 # require it to be present in the URL. You will also likely327 # need to provide a <Directory> section to allow access to328 # the filesystem path.329 330 #331 # ScriptAlias: This controls which directories contain server scripts.332 # ScriptAliases are essentially the same as Aliases,except that333 # documents in the target directory are treated as applications and334 # run by the server when requested rather than as documents sent to the335 # client. The same rules about trailing "/"apply to ScriptAlias336 # directives as to Alias.337 #338 ScriptAlias /cgi-bin/ "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/" 339 340 </IfModule>341 342 <IfModule cgid_module>343 #344 # ScriptSock: On threaded servers,designate the path to the UNIX345 # socket used to communicate with the CGI daemon of mod_cgid.346 #347 #Scriptsock logs/cgisock348 </IfModule>349 350 #351 # "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin"should be changed to whatever your ScriptAliased352 # CGI directory exists,if you have that configured.353 #354 <Directory "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">355 AllowOverride None356 Options None357 Order allow,deny358 Allow from all359 </Directory>360 361 #362 # DefaultType: the default MIME type the server will use for a document363 # if it cannot otherwise determine one,such as from filename extensions.364 # If your server contains mostly text or HTML documents, "text/plain"is365 # a good value. If most of your content is binary,such as applications366 # or images, you may want to use "application/octet-stream"instead to367 # keep browsers from trying to display binary files as though they are368 # text.369 #370 DefaultType text/plain371 372 <IfModule mime_module>373 #374 # TypesConfig points to the file containing the list of mappings from375 # filename extension to MIME-type.376 #377 TypesConfig conf/mime.types378 379 #380 # AddType allows you to add to or override the MIME configuration381 # file specified in TypesConfig for specific file types.382 #383 #AddType application/x-gzip .tgz384 #385 # AddEncoding allows you to have certain browsers uncompress386 # information on the fly. Note: Not all browsers support this.387 #388 #AddEncoding x-compress .Z389 #AddEncoding x-gzip .gz .tgz390 #391 # If the AddEncoding directives above are commented-out,then you392 # probably should define those extensions to indicate media types:393 #394 AddType application/x-compress .Z395 AddType application/x-gzip .gz .tgz396 397 #398 # AddHandler allows you to map certain file extensions to "handlers":399 # actions unrelated to filetype. These can be either built into the server400 # or added with the Action directive (see below)401 #402 # To use CGI scripts outside of ScriptAliased directories:403 # (You will also need to add "ExecCGI" to the "Options"directive.)404 #405 #AddHandler cgi-script .cgi406 407 # For type maps (negotiated resources):408 #AddHandler type-map var409 410 #411 # Filters allow you to process content before it is sent to the client.412 #413 # To parse .shtml files for server-side includes (SSI):414 # (You will also need to add "Includes" to the "Options"directive.)415 #416 #AddType text/html .shtml417 #AddOutputFilter INCLUDES .shtml418 </IfModule>419 420 #421 # The mod_mime_magic module allows the server to use various hints from the422 # contents of the file itself to determine its type. The MIMEMagicFile423 # directive tells the module where the hint definitions are located.424 #425 #MIMEMagicFile conf/magic426 427 #428 # Customizable error responses come in three flavors:429 # 1) plain text 2) local redirects 3) external redirects430 #431 # Some examples:432 #ErrorDocument 500 "The server made a boo boo." 433 #ErrorDocument 404/missing.html434 #ErrorDocument 404 "/cgi-bin/missing_handler.pl" 435 #ErrorDocument 402http://localhost/subscription_info.html436 #437 438 #439 # MaxRanges: Maximum number of Ranges in a request before440 # returning the entire resource,or one of the special441 # values 'default','none' or 'unlimited'.442 # Default setting is to accept 200Ranges.443 #MaxRanges unlimited444 445 #446 # EnableMMAP and EnableSendfile: On systems that support it, 447 # memory-mapping or the sendfile syscall is used to deliver448 # files. This usually improves server performance,but must449 # be turned off when serving from networked-mounted450 # filesystems or if support for these functions is otherwise451 # broken on your system.452 #453 #EnableMMAP off454 #EnableSendfile off455 456 # Supplemental configuration457 #458 # The configuration files in the conf/extra/ directory can be459 # included to add extra features or to modify the default configuration of460 # the server,or you may simply copy their contents here and change as461 # necessary.462 463 # Server-pool management (MPM specific)464 #Include conf/extra/httpd-mpm.conf465 466 # Multi-language error messages467 #Include conf/extra/httpd-multilang-errordoc.conf468 469 # Fancy directory listings470 #Include conf/extra/httpd-autoindex.conf471 472 # Language settings473 #Include conf/extra/httpd-languages.conf474 475 # User home directories476 #Include conf/extra/httpd-userdir.conf477 478 # Real-time info on requests and configuration479 #Include conf/extra/httpd-info.conf480 481 # Virtual hosts482 #Include conf/extra/httpd-vhosts.conf483 484 # Local access to the Apache HTTP Server Manual485 #Include conf/extra/httpd-manual.conf486 487 # Distributed authoring and versioning (WebDAV)488 #Include conf/extra/httpd-dav.conf489 490 # Various default settings491 #Include conf/extra/httpd-default.conf492 493 # Secure (SSL/TLS) connections494 #Include conf/extra/httpd-ssl.conf495 #496 # Note: The following must must be present to support497 # starting without SSL on platforms with no /dev/random equivalent498 # but a statically compiled-in mod_ssl.499 #500 <IfModule ssl_module>501 SSLRandomSeed startup builtin502 SSLRandomSeed connect builtin503 </IfModule>504 include conf/mod_jk.conf
3>workers.properties(apache/conf)
1 #workers.tomcat_home=D:\software\apache-tomcat-6.0.20\apache-tomcat-6.0.20 2 #workers.java_home=C:\Program Files\Java\jdk1.6.0_18\jre3 #ps=\4 #worker.list=ajp135 #worker.ajp13.port=8009 6 #worker.ajp13.host=localhost7 #worker.ajp13.type=ajp138 #worker.ajp13.lbfactor=1 9 #tomcat的路径,让mod_jk模块知道10 workers.tomcat1_home=D:\Program Files\Apache Software Foundation\tomcat111 workers.tomcat2_home=D:\Program Files\Apache Software Foundation\tomcat212 workers.tomcat3_home=D:\Program Files\Apache Software Foundation\tomcat313 #jdk的路径,让mod_jk模块知道jre的位置14 workers.java_home=C:\Program Files\Java\jdk1.6.0_18\jre15 #路径分隔符16 ps=\17 #server 列表(tomcat1,tomcat2,tomcat3为别名)18 worker.list =controller #模块版本19 #========tomcat1======== 20 worker.tomcat1.port=8009 #ajp13 端口号,在tomcat下server.xml配置,默认8009(工作端口,若没占用则不用修改)21 worker.tomcat1.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址22 worker.tomcat1.type=ajp13 #类型23 worker.tomcat1.lbfactor = 1 #server的加权比重,值越高,分得的请求越多(代理数,不用修改)24 #========tomcat2======== 25 worker.tomcat2.port=9009 #ajp13 端口号,在tomcat下server.xml配置,默认800926 worker.tomcat2.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址27 worker.tomcat2.type=ajp1328 worker.tomcat2.lbfactor = 1#server的加权比重,值越高,分得的请求越多29 #========tomcat3======== 30 worker.tomcat3.port=9010 #ajp13 端口号,在tomcat下server.xml配置,默认800931 worker.tomcat3.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址32 worker.tomcat3.type=ajp1333 worker.tomcat3.lbfactor = 1#server的加权比重,值越高,分得的请求越多34 #========controller,负载均衡控制器======== 35 worker.controller.type=lb36 worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3 #指定分担请求的tomcat37 worker.controller.sticky_session=False #粘性会话设置
(2)tomcat配置
1>server.xml(tomcat/conf)
1 <?xml version='1.0' encoding='utf-8'?> 2 <!-- 3 Licensed to the Apache Software Foundation (ASF) under one or more4 contributor license agreements. See the NOTICE file distributed with5 this work for additional information regarding copyright ownership.6 The ASF licenses this file to You under the Apache License, Version 2.07 (the "License"); you may not use this file except in compliance with8 the License. You may obtain a copy of the License at9 10 http://www.apache.org/licenses/LICENSE-2.011 12 Unless required by applicable law or agreed to in writing, software13 distributed under the License is distributed on an "AS IS" BASIS,14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 See the License for the specific language governing permissions and16 limitations under the License.17 --> 18 <!--Note: A "Server" is not itself a "Container", so you may not19 define subcomponents such as "Valves" at this level.20 Documentation at /docs/config/server.html21 --> 22 <Serverport="8005"shutdown="SHUTDOWN"> 23 24 <!--APR library loader. Documentation at /docs/apr.html--> 25 <ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on" /> 26 <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html--> 27 <ListenerclassName="org.apache.catalina.core.JasperListener" /> 28 <!--JMX Support for the Tomcat server. Documentation at /docs/non-existent.html--> 29 <ListenerclassName="org.apache.catalina.mbeans.ServerLifecycleListener" /> 30 <ListenerclassName="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> 31 32 <!--Global JNDI resources33 Documentation at /docs/jndi-resources-howto.html34 --> 35 <GlobalNamingResources> 36 <!--Editable user database that can also be used by37 UserDatabaseRealm to authenticate users38 --> 39 <Resourcename="UserDatabase"auth="Container" 40 type="org.apache.catalina.UserDatabase" 41 description="User database that can be updated and saved" 42 factory="org.apache.catalina.users.MemoryUserDatabaseFactory" 43 pathname="conf/tomcat-users.xml" /> 44 </GlobalNamingResources> 45 46 <!--A "Service" is a collection of one or more "Connectors" that share47 a single "Container" Note: A "Service" is not itself a "Container",48 so you may not define subcomponents such as "Valves" at this level.49 Documentation at /docs/config/service.html50 --> 51 <Servicename="Catalina"> 52 53 <!--The connectors can use a shared executor, you can define one or more named thread pools--> 54 <!--executor--> 55 <Executorname="tomcatThreadPool"namePrefix="catalina-exec-" 56 maxThreads="1000"minSpareThreads="350"/> 57 58 59 <!--A "Connector" represents an endpoint by which requests are received60 and responses are returned. Documentation at :61 Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)62 Java AJP Connector: /docs/config/ajp.html63 APR (HTTP/AJP) Connector: /docs/apr.html64 Define a non-SSL HTTP/1.1 Connector on port 808065 --> 66 <!--type1--> 67 <!-- 68 <Connector port="8080" protocol="HTTP/1.1"69 connectionTimeout="30000"70 redirectPort="8443"71 enableLookups="false"72 maxThreads="1000"73 minSpareThreads="25"74 maxSpareThreads="75"75 acceptCount="1000"76 compression="on"77 compressionMinSize="2048"78 noCompressionUserAgents="gozilla, traviata"79 compressableMimeType="text/html,text/xml,text/css,text/javascript,image/gif,image/jpg"80 URIEncoding="utf-8" />81 --> 82 <!--type2--> 83 <!--openNIO/executor/gzip--> 84 <Connectorexecutor="tomcatThreadPool"port="8080"protocol="org.apache.coyote.http11.Http11NioProtocol" 85 connectionTimeout="30000" 86 redirectPort="8443" 87 enableLookups="false" 88 acceptCount="1000" 89 compression="on" 90 compressionMinSize="2048" 91 noCompressionUserAgents="gozilla, traviata" 92 compressableMimeType="text/html,text/xml,text/css,text/javascript,text/plain,image/gif,image/jpg" 93 URIEncoding="utf-8" /> 94 <!--A "Connector" using the shared thread pool--> 95 <!-- 96 <Connector executor="tomcatThreadPool"97 port="8080" protocol="HTTP/1.1"98 connectionTimeout="20000"99 redirectPort="8443" />100 --> 101 <!--Define a SSL HTTP/1.1 Connector on port 8443102 This connector uses the JSSE configuration, when using APR, the103 connector should be using the OpenSSL style configuration104 described in the APR documentation--> 105 <!-- 106 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"107 maxThreads="150" scheme="https" secure="true"108 clientAuth="false" sslProtocol="TLS" />109 --> 110 111 <!--Define an AJP 1.3 Connector on port 8009--> 112 <Connectorport="8009"protocol="AJP/1.3"redirectPort="8443" /> 113 114 115 <!--An Engine represents the entry point (within Catalina) that processes116 every request. The Engine implementation for Tomcat stand alone117 analyzes the HTTP headers included with the request, and passes them118 on to the appropriate Host (virtual host).119 Documentation at /docs/config/engine.html--> 120 121 <!--You should set jvmRoute to support load-balancing via AJP ie :122 <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">123 --> 124 <Enginename="Catalina"jvmRoute="tomcat1"defaultHost="localhost"> 125 126 <!--For clustering, please take a look at documentation at:127 /docs/cluster-howto.html (simple how to)128 /docs/config/cluster.html (reference documentation)--> 129 130 131 132 <ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster" 133 channelSendOptions="6"> 134 135 <ManagerclassName="org.apache.catalina.ha.session.BackupManager" 136 expireSessionsOnShutdown="false" 137 notifyListenersOnReplication="true" 138 mapSendOptions="6"/> 139 <!-- 140 <Manager className="org.apache.catalina.ha.session.DeltaManager"141 expireSessionsOnShutdown="false"142 notifyListenersOnReplication="true"/>143 --> 144 <ChannelclassName="org.apache.catalina.tribes.group.GroupChannel"> 145 <MembershipclassName="org.apache.catalina.tribes.membership.McastService" 146 address="228.0.0.4" 147 port="45564" 148 frequency="500" 149 dropTime="3000"/> 150 <ReceiverclassName="org.apache.catalina.tribes.transport.nio.NioReceiver" 151 address="auto" 152 port="5000" 153 selectorTimeout="100" 154 maxThreads="6"/> 155 156 <SenderclassName="org.apache.catalina.tribes.transport.ReplicationTransmitter"> 157 <TransportclassName="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> 158 </Sender> 159 <InterceptorclassName="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/> 160 <InterceptorclassName="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/> 161 <InterceptorclassName="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> 162 </Channel> 163 164 <ValveclassName="org.apache.catalina.ha.tcp.ReplicationValve" 165 filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/> 166 167 <!-- 168 <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"169 tempDir="/tmp/war-temp/"170 deployDir="/tmp/war-deploy/"171 watchDir="/tmp/war-listen/"172 watchEnabled="false"/>173 --> 174 175 <ClusterListenerclassName="org.apache.catalina.ha.session.ClusterSessionListener"/> 176 </Cluster> 177 178 <!--The request dumper valve dumps useful debugging information about179 the request and response data received and sent by Tomcat.180 Documentation at: /docs/config/valve.html--> 181 <!-- 182 <Valve className="org.apache.catalina.valves.RequestDumperValve"/>183 --> 184 185 <!--This Realm uses the UserDatabase configured in the global JNDI186 resources under the key "UserDatabase". Any edits187 that are performed against this UserDatabase are immediately188 available for use by the Realm.--> 189 <RealmclassName="org.apache.catalina.realm.UserDatabaseRealm" 190 resourceName="UserDatabase"/> 191 192 <!--Define the default virtual host193 Note: XML Schema validation will not work with Xerces 2.2.194 --> 195 <Hostname="localhost"appBase="webapps" 196 unpackWARs="true"autoDeploy="true" 197 xmlValidation="false"xmlNamespaceAware="false"> 198 199 <!--SingleSignOn valve, share authentication between web applications200 Documentation at: /docs/config/valve.html--> 201 <!-- 202 <Valve className="org.apache.catalina.authenticator.SingleSignOn" />203 --> 204 205 <!--Access log processes all example.206 Documentation at: /docs/config/valve.html--> 207 <!-- 208 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"209 prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>210 --> 211 212 </Host> 213 </Engine> 214 </Service> 215 </Server>
2>web.xml(tomcat/conf)
<?xml version="1.0" encoding="ISO-8859-1"?> <!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--> <web-appxmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"version="2.5"> <!--======================== Introduction ==============================--> <!--This document defines default values for *all* web applications--> <!--loaded into this instance of Tomcat. As each application is--> <!--deployed, this file is processed, followed by the--> <!--"/WEB-INF/web.xml" deployment descriptor from your own--> <!--applications.--> <!-- --> <!--WARNING: Do not configure application-specific resources here!--> <!--They should go in the "/WEB-INF/web.xml" file in your application.--><!--================== Built In Servlet Definitions ====================--><!--The default servlet for all web applications, that serves static--> <!--resources. It processes all requests that are not mapped to other--> <!--servlets with servlet mappings (defined either here or in your own--> <!--web.xml file. This servlet supports the following initialization--> <!--parameters (default values are in square brackets):--> <!-- --> <!--debug Debugging detail level for messages logged--> <!--by this servlet. [0]--> <!-- --> <!--fileEncoding Encoding to be used to read static resources--> <!--[platform default]--> <!-- --> <!--input Input buffer size (in bytes) when reading--> <!--resources to be served. [2048]--> <!-- --> <!--listings Should directory listings be produced if there--> <!--is no welcome file in this directory? [false]--> <!--WARNING: Listings for directories with many--> <!--entries can be slow and may consume--> <!--significant proportions of server resources.--> <!-- --> <!--output Output buffer size (in bytes) when writing--> <!--resources to be served. [2048]--> <!-- --> <!--readonly Is this context "read only", so HTTP--> <!--commands like PUT and DELETE are--> <!--rejected? [true]--> <!-- --> <!--readmeFile File name to display with the directory--> <!--contents. [null]--> <!-- --> <!--sendfileSize If the connector used supports sendfile, this--> <!--represents the minimal file size in KB for--> <!--which sendfile will be used. Use a negative--> <!--value to always disable sendfile. [48]--> <!-- --> <!--For directory listing customization. Checks localXsltFile, then--> <!--globalXsltFile, then defaults to original behavior.--> <!-- --> <!--localXsltFile Make directory listings an XML doc and--> <!--pass the result to this style sheet residing--> <!--in that directory. This overrides--> <!--globalXsltFile[null]--> <!-- --> <!--globalXsltFile Site wide configuration version of--> <!--localXsltFile This argument is expected--> <!--to be a physical file. [null]--> <!-- --> <!-- --> <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet><!--The "invoker" servlet, which executes anonymous servlet classes--> <!--that have not been defined in a web.xml file. Traditionally, this--> <!--servlet is mapped to the URL pattern "/servlet/*", but you can map--> <!--it to other patterns as well. The extra path info portion of such a--> <!--request must be the fully qualified class name of a Java class that--> <!--implements Servlet (or extends HttpServlet), or the servlet name--> <!--of an existing servlet definition. This servlet supports the--> <!--following initialization parameters (default values are in square--> <!--brackets):--> <!-- --> <!--debug Debugging detail level for messages logged--> <!--by this servlet. [0]--> <!--<servlet> <servlet-name>invoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>--><!--The JSP page compiler and execution servlet, which is the mechanism--> <!--used by Tomcat to support JSP pages. Traditionally, this servlet--> <!--is mapped to the URL pattern "*.jsp". This servlet supports the--> <!--following initialization parameters (default values are in square--> <!--brackets):--> <!-- --> <!--checkInterval If development is false and checkInterval is--> <!--greater than zero, background compilations are--> <!--enabled. checkInterval is the time in seconds--> <!--between checks to see if a JSP page (and its--> <!--dependent files) needs to be recompiled. [0]--> <!-- --> <!--classdebuginfo Should the class file be compiled with--> <!--debugging information? [true]--> <!-- --> <!--classpath What class path should I use while compiling--> <!--generated servlets? [Created dynamically--> <!--based on the current web application]--> <!-- --> <!--compiler Which compiler Ant should use to compile JSP--> <!--pages. See the jasper documentation for more--> <!--information.--> <!-- --> <!--compilerSourceVM Compiler source VM--> <!--default is System.properties--> <!--java.specification.version > 1.4--> <!--[1.5] else [1.4]--> <!-- --> <!--compilerTargetVM Compiler target VM--> <!--default is System.properties--> <!--java.specification.version > 1.4--> <!--[1.5] else [1.4]--> <!-- --> <!--development Is Jasper used in development mode? If true,--> <!--the frequency at which JSPs are checked for--> <!--modification may be specified via the--> <!--modificationTestInterval parameter. [true]--> <!-- --> <!--displaySourceFragment--> <!--Should a source fragment be included in--> <!--exception messages? [true]--> <!-- --> <!--dumpSmap Should the SMAP info for JSR45 debugging be--> <!--dumped to a file? [false]--> <!--False if suppressSmap is true--> <!-- --> <!--enablePooling Determines whether tag handler pooling is--> <!--enabled [true]--> <!-- --> <!--engineOptionsClass Allows specifying the Options class used to--> <!--configure Jasper. If not present, the default--> <!--EmbeddedServletOptions will be used.--> <!-- --> <!--errorOnUseBeanInvalidClassAttribute--> <!--Should Jasper issue an error when the value of--> <!--the class attribute in an useBean action is--> <!--not a valid bean class? [true]--> <!-- --> <!--fork Tell Ant to fork compiles of JSP pages so that--> <!--a separate JVM is used for JSP page compiles--> <!--from the one Tomcat is running in. [true]--> <!-- --> <!--genStrAsCharArray Should text strings be generated as char--> <!--arrays, to improve performance in some cases?--> <!--[false]--> <!-- --> <!--ieClassId The class-id value to be sent to Internet--> <!--Explorer when using <jsp:plugin> tags.--> <!--[clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]--> <!-- --> <!--javaEncoding Java file encoding to use for generating java--> <!--source files. [UTF8]--> <!-- --> <!--keepgenerated Should we keep the generated Java source code--> <!--for each page instead of deleting it? [true]--> <!-- --> <!--mappedfile Should we generate static content with one--> <!--print statement per input line, to ease--> <!--debugging? [true]--> <!-- --> <!--modificationTestInterval--> <!--Causes a JSP (and its dependent files) to not--> <!--be checked for modification during the--> <!--specified time interval (in seconds) from the--> <!--last time the JSP was checked for--> <!--modification. A value of 0 will cause the JSP--> <!--to be checked on every access.--> <!--Used in development mode only. [4]--> <!-- --> <!--scratchdir What scratch directory should we use when--> <!--compiling JSP pages? [default work directory--> <!--for the current web application]--> <!-- --> <!--suppressSmap Should the generation of SMAP info for JSR45--> <!--debugging be suppressed? [false]--> <!-- --> <!--trimSpaces Should white spaces in template text between--> <!--actions or directives be trimmed? [false]--> <!-- --> <!--xpoweredBy Determines whether X-Powered-By response--> <!--header is added by generated servlet [false]--> <!-- --> <!--If you wish to use Jikes to compile JSP pages:--> <!--Please see the "Using Jikes" section of the Jasper-HowTo--> <!--page in the Tomcat documentation.--> <servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>fork</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>xpoweredBy</param-name> <param-value>false</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet><!--NOTE: An SSI Filter is also available as an alternative SSI--> <!--implementation. Use either the Servlet or the Filter but NOT both.--> <!-- --> <!--Server Side Includes processing servlet, which processes SSI--> <!--directives in HTML pages consistent with similar support in web--> <!--servers like Apache. Traditionally, this servlet is mapped to the--> <!--URL pattern "*.shtml". This servlet supports the following--> <!--initialization parameters (default values are in square brackets):--> <!-- --> <!--buffered Should output from this servlet be buffered?--> <!--(0=false, 1=true) [0]--> <!-- --> <!--debug Debugging detail level for messages logged--> <!--by this servlet. [0]--> <!-- --> <!--expires The number of seconds before a page with SSI--> <!--directives will expire. [No default]--> <!-- --> <!--isVirtualWebappRelative--> <!--Should "virtual" paths be interpreted as--> <!--relative to the context root, instead of--> <!--the server root? (0=false, 1=true) [0]--> <!-- --> <!--inputEncoding The encoding to assume for SSI resources if--> <!--one is not available from the resource.--> <!--[Platform default]--> <!-- --> <!--outputEncoding The encoding to use for the page that results--> <!--from the SSI processing. [UTF-8]--> <!--<servlet> <servlet-name>ssi</servlet-name> <servlet-class> org.apache.catalina.ssi.SSIServlet </servlet-class> <init-param> <param-name>buffered</param-name> <param-value>1</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>expires</param-name> <param-value>666</param-value> </init-param> <init-param> <param-name>isVirtualWebappRelative</param-name> <param-value>0</param-value> </init-param> <load-on-startup>4</load-on-startup> </servlet>--><!--Common Gateway Includes (CGI) processing servlet, which supports--> <!--execution of external applications that conform to the CGI spec--> <!--requirements. Typically, this servlet is mapped to the URL pattern--> <!--"/cgi-bin/*", which means that any CGI applications that are--> <!--executed must be present within the web application. This servlet--> <!--supports the following initialization parameters (default values--> <!--are in square brackets):--> <!-- --> <!--cgiPathPrefix The CGI search path will start at--> <!--webAppRootDir + File.separator + this prefix.--> <!--[WEB-INF/cgi]--> <!-- --> <!--debug Debugging detail level for messages logged--> <!--by this servlet. [0]--> <!-- --> <!--executable Name of the exectuable used to run the--> <!--script. [perl]--> <!-- --> <!--parameterEncoding Name of parameter encoding to be used with--> <!--CGI servlet.--> <!--[System.getProperty("file.encoding","UTF-8")]--> <!-- --> <!--passShellEnvironment Should the shell environment variables (if--> <!--any) be passed to the CGI script? [false]--> <!--<servlet> <servlet-name>cgi</servlet-name> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi</param-value> </init-param> <load-on-startup>5</load-on-startup> </servlet>--><!--================ Built In Servlet Mappings =========================--><!--The servlet mappings for the built in servlets defined above. Note--> <!--that, by default, the CGI and SSI servlets are *not* mapped. You--> <!--must uncomment these mappings (or add them to your application's own--> <!--web.xml deployment descriptor) to enable these services--> <!--The mapping for the default servlet--> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!--The mapping for the invoker servlet--> <!--<servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>--> <!--The mapping for the JSP servlet--> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jspx</url-pattern> </servlet-mapping> <!--The mapping for the SSI servlet--> <!--<servlet-mapping> <servlet-name>ssi</servlet-name> <url-pattern>*.shtml</url-pattern> </servlet-mapping>--> <!--The mapping for the CGI Gateway servlet--> <!--<servlet-mapping> <servlet-name>cgi</servlet-name> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping>--><!--================== Built In Filter Definitions =====================--> <!--NOTE: An SSI Servlet is also available as an alternative SSI--> <!--implementation. Use either the Servlet or the Filter but NOT both.--> <!-- --> <!--Server Side Includes processing filter, which processes SSI--> <!--directives in HTML pages consistent with similar support in web--> <!--servers like Apache. Traditionally, this filter is mapped to the--> <!--URL pattern "*.shtml", though it can be mapped to "*" as it will--> <!--selectively enable/disable SSI processing based on mime types. For--> <!--this to work you will need to uncomment the .shtml mime type--> <!--definition towards the bottom of this file.--> <!--The contentType init param allows you to apply SSI processing to JSP--> <!--pages, javascript, or any other content you wish. This filter--> <!--supports the following initialization parameters (default values are--> <!--in square brackets):--> <!-- --> <!--contentType A regex pattern that must be matched before--> <!--SSI processing is applied.--> <!--[text/x-server-parsed-html(;.*)?]--> <!-- --> <!--debug Debugging detail level for messages logged--> <!--by this servlet. [0]--> <!-- --> <!--expires The number of seconds before a page with SSI--> <!--directives will expire. [No default]--> <!-- --> <!--isVirtualWebappRelative--> <!--Should "virtual" paths be interpreted as--> <!--relative to the context root, instead of--> <!--the server root? (0=false, 1=true) [0]--> <!--<filter> <filter-name>ssi</filter-name> <filter-class> org.apache.catalina.ssi.SSIFilter </filter-class> <init-param> <param-name>contentType</param-name> <param-value>text/x-server-parsed-html(;.*)?</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>expires</param-name> <param-value>666</param-value> </init-param> <init-param> <param-name>isVirtualWebappRelative</param-name> <param-value>0</param-value> </init-param> </filter>--><!--==================== Built In Filter Mappings ======================--> <!--The mapping for the SSI Filter--> <!--<filter-mapping> <filter-name>ssi</filter-name> <url-pattern>*.shtml</url-pattern> </filter-mapping>--><!--==================== Default Session Configuration =================--> <!--You can set the default session timeout (in minutes) for all newly--> <!--created sessions by modifying the value below.--> <session-config> <session-timeout>30</session-timeout> </session-config><!--===================== Default MIME Type Mappings ===================--> <!--When serving static resources, Tomcat will automatically generate--> <!--a "Content-Type" header based on the resource's filename extension,--> <!--based on these mappings. Additional mappings can be added here (to--> <!--apply to all web applications), or in your own application's web.xml--> <!--deployment descriptor.--> <mime-mapping> <extension>abs</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>ai</extension> <mime-type>application/postscript</mime-type> </mime-mapping> <mime-mapping> <extension>aif</extension> <mime-type>audio/x-aiff</mime-type> </mime-mapping> <mime-mapping> <extension>aifc</extension> <mime-type>audio/x-aiff</mime-type> </mime-mapping> <mime-mapping> <extension>aiff</extension> <mime-type>audio/x-aiff</mime-type> </mime-mapping> <mime-mapping> <extension>aim</extension> <mime-type>application/x-aim</mime-type> </mime-mapping> <mime-mapping> <extension>art</extension> <mime-type>image/x-jg</mime-type> </mime-mapping> <mime-mapping> <extension>asf</extension> <mime-type>video/x-ms-asf</mime-type> </mime-mapping> <mime-mapping> <extension>asx</extension> <mime-type>video/x-ms-asf</mime-type> </mime-mapping> <mime-mapping> <extension>au</extension> <mime-type>audio/basic</mime-type> </mime-mapping> <mime-mapping> <extension>avi</extension> <mime-type>video/x-msvideo</mime-type> </mime-mapping> <mime-mapping> <extension>avx</extension> <mime-type>video/x-rad-screenplay</mime-type> </mime-mapping> <mime-mapping> <extension>bcpio</extension> <mime-type>application/x-bcpio</mime-type> </mime-mapping> <mime-mapping> <extension>bin</extension> <mime-type>application/octet-stream</mime-type> </mime-mapping> <mime-mapping> <extension>bmp</extension> <mime-type>image/bmp</mime-type> </mime-mapping> <mime-mapping> <extension>body</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>cdf</extension> <mime-type>application/x-cdf</mime-type> </mime-mapping> <mime-mapping> <extension>cer</extension><mime-type>application/x-x509-ca-cert</mime-type> </mime-mapping> <mime-mapping> <extension>class</extension> <mime-type>application/java</mime-type> </mime-mapping> <mime-mapping> <extension>cpio</extension> <mime-type>application/x-cpio</mime-type> </mime-mapping> <mime-mapping> <extension>csh</extension> <mime-type>application/x-csh</mime-type> </mime-mapping> <mime-mapping> <extension>css</extension> <mime-type>text/css</mime-type> </mime-mapping> <mime-mapping> <extension>dib</extension> <mime-type>image/bmp</mime-type> </mime-mapping> <mime-mapping> <extension>doc</extension> <mime-type>application/msword</mime-type> </mime-mapping> <mime-mapping> <extension>dtd</extension> <mime-type>application/xml-dtd</mime-type> </mime-mapping> <mime-mapping> <extension>dv</extension> <mime-type>video/x-dv</mime-type> </mime-mapping> <mime-mapping> <extension>dvi</extension> <mime-type>application/x-dvi</mime-type> </mime-mapping> <mime-mapping> <extension>eps</extension> <mime-type>application/postscript</mime-type> </mime-mapping> <mime-mapping> <extension>etx</extension> <mime-type>text/x-setext</mime-type> </mime-mapping> <mime-mapping> <extension>exe</extension> <mime-type>application/octet-stream</mime-type> </mime-mapping> <mime-mapping> <extension>gif</extension> <mime-type>image/gif</mime-type> </mime-mapping> <mime-mapping> <extension>gtar</extension> <mime-type>application/x-gtar</mime-type> </mime-mapping> <mime-mapping> <extension>gz</extension> <mime-type>application/x-gzip</mime-type> </mime-mapping> <mime-mapping> <extension>hdf</extension> <mime-type>application/x-hdf</mime-type> </mime-mapping> <mime-mapping> <extension>hqx</extension> <mime-type>application/mac-binhex40</mime-type> </mime-mapping> <mime-mapping> <extension>htc</extension> <mime-type>text/x-component</mime-type> </mime-mapping> <mime-mapping> <extension>htm</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>html</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>hqx</extension> <mime-type>application/mac-binhex40</mime-type> </mime-mapping> <mime-mapping> <extension>ief</extension> <mime-type>image/ief</mime-type> </mime-mapping> <mime-mapping> <extension>jad</extension> <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type> </mime-mapping> <mime-mapping> <extension>jar</extension> <mime-type>application/java-archive</mime-type> </mime-mapping> <mime-mapping> <extension>java</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping> <extension>jpe</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>jpeg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>jpg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>js</extension> <mime-type>text/javascript</mime-type> </mime-mapping> <mime-mapping> <extension>jsf</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping> <extension>jspf</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping> <extension>kar</extension> <mime-type>audio/x-midi</mime-type> </mime-mapping> <mime-mapping> <extension>latex</extension> <mime-type>application/x-latex</mime-type> </mime-mapping> <mime-mapping> <extension>m3u</extension> <mime-type>audio/x-mpegurl</mime-type> </mime-mapping> <mime-mapping> <extension>mac</extension> <mime-type>image/x-macpaint</mime-type> </mime-mapping> <mime-mapping> <extension>man</extension> <mime-type>application/x-troff-man</mime-type> </mime-mapping> <mime-mapping> <extension>mathml</extension> <mime-type>application/mathml+xml</mime-type> </mime-mapping> <mime-mapping> <extension>me</extension> <mime-type>application/x-troff-me</mime-type> </mime-mapping> <mime-mapping> <extension>mid</extension> <mime-type>audio/x-midi</mime-type> </mime-mapping> <mime-mapping> <extension>midi</extension><mime-type>audio/x-midi</mime-type> </mime-mapping> <mime-mapping> <extension>mif</extension> <mime-type>application/x-mif</mime-type> </mime-mapping> <mime-mapping> <extension>mov</extension> <mime-type>video/quicktime</mime-type> </mime-mapping> <mime-mapping> <extension>movie</extension> <mime-type>video/x-sgi-movie</mime-type> </mime-mapping> <mime-mapping> <extension>mp1</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mp2</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mp3</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mp4</extension> <mime-type>video/mp4</mime-type> </mime-mapping> <mime-mapping> <extension>mpa</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mpe</extension> <mime-type>video/mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mpeg</extension> <mime-type>video/mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mpega</extension> <mime-type>audio/x-mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mpg</extension> <mime-type>video/mpeg</mime-type> </mime-mapping> <mime-mapping> <extension>mpv2</extension> <mime-type>video/mpeg2</mime-type> </mime-mapping> <mime-mapping> <extension>ms</extension> <mime-type>application/x-wais-source</mime-type> </mime-mapping> <mime-mapping> <extension>nc</extension> <mime-type>application/x-netcdf</mime-type> </mime-mapping> <mime-mapping> <extension>oda</extension> <mime-type>application/oda</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Database--> <extension>odb</extension> <mime-type>application/vnd.oasis.opendocument.database</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Chart--> <extension>odc</extension> <mime-type>application/vnd.oasis.opendocument.chart</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Formula--> <extension>odf</extension> <mime-type>application/vnd.oasis.opendocument.formula</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Drawing--> <extension>odg</extension> <mime-type>application/vnd.oasis.opendocument.graphics</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Image--> <extension>odi</extension> <mime-type>application/vnd.oasis.opendocument.image</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Master Document--> <extension>odm</extension> <mime-type>application/vnd.oasis.opendocument.text-master</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Presentation--> <extension>odp</extension> <mime-type>application/vnd.oasis.opendocument.presentation</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Spreadsheet--> <extension>ods</extension> <mime-type>application/vnd.oasis.opendocument.spreadsheet</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Text--> <extension>odt</extension> <mime-type>application/vnd.oasis.opendocument.text</mime-type> </mime-mapping> <mime-mapping> <extension>ogg</extension> <mime-type>application/ogg</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Drawing Template--> <extension>otg </extension> <mime-type>application/vnd.oasis.opendocument.graphics-template</mime-type> </mime-mapping> <mime-mapping> <!--HTML Document Template--> <extension>oth</extension> <mime-type>application/vnd.oasis.opendocument.text-web</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Presentation Template--> <extension>otp</extension> <mime-type>application/vnd.oasis.opendocument.presentation-template</mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Spreadsheet Template--> <extension>ots</extension> <mime-type>application/vnd.oasis.opendocument.spreadsheet-template </mime-type> </mime-mapping> <mime-mapping> <!--OpenDocument Text Template--> <extension>ott</extension> <mime-type>application/vnd.oasis.opendocument.text-template</mime-type> </mime-mapping> <mime-mapping> <extension>pbm</extension> <mime-type>image/x-portable-bitmap</mime-type> </mime-mapping> <mime-mapping> <extension>pct</extension> <mime-type>image/pict</mime-type> </mime-mapping> <mime-mapping> <extension>pdf</extension> <mime-type>application/pdf</mime-type> </mime-mapping> <mime-mapping> <extension>pgm</extension> <mime-type>image/x-portable-graymap</mime-type> </mime-mapping> <mime-mapping> <extension>pic</extension> <mime-type>image/pict</mime-type> </mime-mapping> <mime-mapping> <extension>pict</extension> <mime-type>image/pict</mime-type> </mime-mapping> <mime-mapping> <extension>pls</extension> <mime-type>audio/x-scpls</mime-type> </mime-mapping> <mime-mapping> <extension>png</extension> <mime-type>image/png</mime-type> </mime-mapping> <mime-mapping> <extension>pnm</extension> <mime-type>image/x-portable-anymap</mime-type> </mime-mapping> <mime-mapping> <extension>pnt</extension> <mime-type>image/x-macpaint</mime-type> </mime-mapping> <mime-mapping> <extension>ppm</extension> <mime-type>image/x-portable-pixmap</mime-type> </mime-mapping> <mime-mapping> <extension>ppt</extension> <mime-type>application/powerpoint</mime-type> </mime-mapping> <mime-mapping> <extension>ps</extension> <mime-type>application/postscript</mime-type> </mime-mapping> <mime-mapping> <extension>psd</extension> <mime-type>image/x-photoshop</mime-type> </mime-mapping> <mime-mapping> <extension>qt</extension> <mime-type>video/quicktime</mime-type> </mime-mapping> <mime-mapping> <extension>qti</extension> <mime-type>image/x-quicktime</mime-type> </mime-mapping> <mime-mapping> <extension>qtif</extension> <mime-type>image/x-quicktime</mime-type> </mime-mapping> <mime-mapping> <extension>ras</extension> <mime-type>image/x-cmu-raster</mime-type> </mime-mapping> <mime-mapping> <extension>rdf</extension> <mime-type>application/rdf+xml</mime-type> </mime-mapping> <mime-mapping> <extension>rgb</extension> <mime-type>image/x-rgb</mime-type> </mime-mapping> <mime-mapping> <extension>rm</extension> <mime-type>application/vnd.rn-realmedia</mime-type> </mime-mapping> <mime-mapping> <extension>roff</extension> <mime-type>application/x-troff</mime-type> </mime-mapping> <mime-mapping> <extension>rtf</extension> <mime-type>application/rtf</mime-type> </mime-mapping> <mime-mapping> <extension>rtx</extension> <mime-type>text/richtext</mime-type> </mime-mapping> <mime-mapping> <extension>sh</extension> <mime-type>application/x-sh</mime-type> </mime-mapping> <mime-mapping> <extension>shar</extension> <mime-type>application/x-shar</mime-type> </mime-mapping> <!--<mime-mapping> <extension>shtml</extension> <mime-type>text/x-server-parsed-html</mime-type> </mime-mapping>--> <mime-mapping> <extension>smf</extension> <mime-type>audio/x-midi</mime-type> </mime-mapping> <mime-mapping> <extension>sit</extension> <mime-type>application/x-stuffit</mime-type> </mime-mapping> <mime-mapping> <extension>snd</extension> <mime-type>audio/basic</mime-type> </mime-mapping> <mime-mapping> <extension>src</extension> <mime-type>application/x-wais-source</mime-type> </mime-mapping> <mime-mapping> <extension>sv4cpio</extension> <mime-type>application/x-sv4cpio</mime-type> </mime-mapping> <mime-mapping> <extension>sv4crc</extension> <mime-type>application/x-sv4crc</mime-type> </mime-mapping> <mime-mapping> <extension>swf</extension> <mime-type>application/x-shockwave-flash</mime-type> </mime-mapping> <mime-mapping> <extension>t</extension> <mime-type>application/x-troff</mime-type> </mime-mapping> <mime-mapping> <extension>tar</extension> <mime-type>application/x-tar</mime-type> </mime-mapping> <mime-mapping> <extension>tcl</extension> <mime-type>application/x-tcl</mime-type> </mime-mapping> <mime-mapping> <extension>tex</extension> <mime-type>application/x-tex</mime-type> </mime-mapping> <mime-mapping> <extension>texi</extension> <mime-type>application/x-texinfo</mime-type> </mime-mapping> <mime-mapping> <extension>texinfo</extension> <mime-type>application/x-texinfo</mime-type> </mime-mapping> <mime-mapping> <extension>tif</extension> <mime-type>image/tiff</mime-type> </mime-mapping> <mime-mapping> <extension>tiff</extension> <mime-type>image/tiff</mime-type> </mime-mapping> <mime-mapping> <extension>tr</extension> <mime-type>application/x-troff</mime-type> </mime-mapping> <mime-mapping> <extension>tsv</extension> <mime-type>text/tab-separated-values</mime-type> </mime-mapping> <mime-mapping> <extension>txt</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping> <extension>ulw</extension> <mime-type>audio/basic</mime-type> </mime-mapping> <mime-mapping> <extension>ustar</extension> <mime-type>application/x-ustar</mime-type> </mime-mapping> <mime-mapping> <extension>vxml</extension> <mime-type>application/voicexml+xml</mime-type> </mime-mapping> <mime-mapping> <extension>xbm</extension> <mime-type>image/x-xbitmap</mime-type> </mime-mapping> <mime-mapping> <extension>xht</extension> <mime-type>application/xhtml+xml</mime-type> </mime-mapping> <mime-mapping> <extension>xhtml</extension> <mime-type>application/xhtml+xml</mime-type> </mime-mapping> <mime-mapping> <extension>xml</extension> <mime-type>application/xml</mime-type> </mime-mapping> <mime-mapping> <extension>xpm</extension> <mime-type>image/x-xpixmap</mime-type> </mime-mapping> <mime-mapping> <extension>xsl</extension> <mime-type>application/xml</mime-type> </mime-mapping> <mime-mapping> <extension>xslt</extension> <mime-type>application/xslt+xml</mime-type> </mime-mapping> <mime-mapping> <extension>xul</extension> <mime-type>application/vnd.mozilla.xul+xml</mime-type> </mime-mapping> <mime-mapping> <extension>xwd</extension> <mime-type>image/x-xwindowdump</mime-type> </mime-mapping> <mime-mapping> <extension>wav</extension> <mime-type>audio/x-wav</mime-type> </mime-mapping> <mime-mapping> <extension>svg</extension> <mime-type>image/svg+xml</mime-type> </mime-mapping> <mime-mapping> <extension>svgz</extension> <mime-type>image/svg+xml</mime-type> </mime-mapping> <mime-mapping> <extension>vsd</extension> <mime-type>application/x-visio</mime-type> </mime-mapping> <mime-mapping> <!--Wireless Bitmap--> <extension>wbmp</extension> <mime-type>image/vnd.wap.wbmp</mime-type> </mime-mapping> <mime-mapping> <!--WML Source--> <extension>wml</extension> <mime-type>text/vnd.wap.wml</mime-type> </mime-mapping> <mime-mapping> <!--Compiled WML--> <extension>wmlc</extension> <mime-type>application/vnd.wap.wmlc</mime-type> </mime-mapping> <mime-mapping> <!--WML Script Source--> <extension>wmls</extension> <mime-type>text/vnd.wap.wmlscript</mime-type> </mime-mapping> <mime-mapping> <!--Compiled WML Script--> <extension>wmlscriptc</extension> <mime-type>application/vnd.wap.wmlscriptc</mime-type> </mime-mapping> <mime-mapping> <extension>wmv</extension> <mime-type>video/x-ms-wmv</mime-type> </mime-mapping> <mime-mapping> <extension>wrl</extension> <mime-type>x-world/x-vrml</mime-type> </mime-mapping> <mime-mapping> <extension>wspolicy</extension> <mime-type>application/wspolicy+xml</mime-type> </mime-mapping> <mime-mapping> <extension>Z</extension> <mime-type>application/x-compress</mime-type> </mime-mapping> <mime-mapping> <extension>z</extension> <mime-type>application/x-compress</mime-type> </mime-mapping> <mime-mapping> <extension>zip</extension> <mime-type>application/zip</mime-type> </mime-mapping> <mime-mapping> <extension>xls</extension> <mime-type>application/vnd.ms-excel</mime-type> </mime-mapping> <mime-mapping> <extension>doc</extension> <mime-type>application/vnd.ms-word</mime-type> </mime-mapping> <mime-mapping> <extension>ppt</extension> <mime-type>application/vnd.ms-powerpoint</mime-type> </mime-mapping> <!--==================== Default Welcome File List =====================--> <!--When a request URI refers to a directory, the default servlet looks--> <!--for a "welcome file" within that directory and, if present,--> <!--to the corresponding resource URI for display. If no welcome file--> <!--is present, the default servlet either serves a directory listing,--> <!--or returns a 404 status, depending on how it is configured.--> <!-- --> <!--If you define welcome files in your own application's web.xml--> <!--deployment descriptor, that list *replaces* the list configured--> <!--here, so be sure that you include any of the default values that--> <!--you wish to include.--> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
3>catalina.bat(tomcat/bin)这个文件只是添加了一个对tomcat内存优化配置的更改(前两行)
1 set CATALINA_OPTS=-Xms256m -Xmx256m2 set JAVA_OPTS=-Xms256m -Xmx256m3 @echo off 4 remLicensed to the Apache Software Foundation (ASF) under one or more 5 remcontributor license agreements. See the NOTICE file distributed with 6 remthis work for additional information regarding copyright ownership. 7 remThe ASF licenses this file to You under the Apache License, Version 2.0 8 rem(the "License"); you may not use this file except in compliance with 9 remthe License. You may obtain a copy of the License at 10 rem11 remhttp://www.apache.org/licenses/LICENSE-2.0 12 rem13 remUnless required by applicable law or agreed to in writing, software 14 remdistributed under the License is distributed on an "AS IS" BASIS, 15 remWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 remSee the License for the specific language governing permissions and 17 remlimitations under the License. 18 19 if "%OS%" == "Windows_NT" setlocal 20 rem--------------------------------------------------------------------------- 21 remStart/Stop Script for the CATALINA Server 22 rem23 remEnvironment Variable Prequisites 24 rem25 remCATALINA_HOME May point at your Catalina "build" directory. 26 rem27 remCATALINA_BASE (Optional) Base directory for resolving dynamic portions 28 remof a Catalina installation. If not present, resolves to 29 remthe same directory that CATALINA_HOME points to. 30 rem31 remCATALINA_OPTS (Optional) Java runtime options used when the "start", 32 remor "run" command is executed. 33 rem34 remCATALINA_TMPDIR (Optional) Directory path location of temporary directory 35 remthe JVM should use (java.io.tmpdir). Defaults to 36 rem%CATALINA_BASE%\temp. 37 rem38 remJAVA_HOME Must point at your Java Development Kit installation. 39 remRequired to run the with the "debug" argument. 40 rem41 remJRE_HOME Must point at your Java Runtime installation. 42 remDefaults to JAVA_HOME if empty. 43 rem44 remJAVA_OPTS (Optional) Java runtime options used when the "start", 45 rem"stop", or "run" command is executed. 46 rem47 remJSSE_HOME (Optional) May point at your Java Secure Sockets Extension 48 rem(JSSE) installation, whose JAR files will be added to the 49 remsystem class path used to start Tomcat. 50 rem51 remJPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" 52 remcommand is executed. The default is "dt_shmem". 53 rem54 remJPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" 55 remcommand is executed. The default is "jdbconn". 56 rem57 remJPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" 58 remcommand is executed. Specifies whether JVM should suspend 59 remexecution immediately after startup. Default is "n". 60 rem61 remJPDA_OPTS (Optional) Java runtime options used when the "jpda start" 62 remcommand is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, 63 remand JPDA_SUSPEND are ignored. Thus, all required jpda 64 remoptions MUST be specified. The default is: 65 rem66 rem-Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%, 67 remaddress=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% 68 rem69 rem$Id: catalina.bat 656834 2008-05-15 21:04:04Z markt $ 70 rem--------------------------------------------------------------------------- 71 72 remGuess CATALINA_HOME if not defined 73 set CURRENT_DIR=%cd%74 if not "%CATALINA_HOME%" == "" gotogotHome75 set CATALINA_HOME=%CURRENT_DIR%76 if exist "%CATALINA_HOME%\bin\catalina.bat" gotookHome77 cd .. 78 set CATALINA_HOME=%cd%79 cd%CURRENT_DIR%80 :gotHome 81 if exist "%CATALINA_HOME%\bin\catalina.bat" gotookHome82 echo The CATALINA_HOME environment variable is notdefined correctly83 echo This environment variable is needed to runthis program84 goto end 85 :okHome 86 87 remGet standard environment variables 88 if "%CATALINA_BASE%" == "" gotogotSetenvHome89 if exist "%CATALINA_BASE%\bin\setenv.bat" call "%CATALINA_BASE%\bin\setenv.bat" 90 gotogotSetenvBase91 :gotSetenvHome 92 if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" 93 :gotSetenvBase 94 95 remGet standard Java environment variables 96 if exist "%CATALINA_HOME%\bin\setclasspath.bat" gotookSetclasspath97 echo Cannot find %CATALINA_HOME%\bin\setclasspath.bat98 echo This file is needed to runthis program99 goto end 100 :okSetclasspath 101 set BASEDIR=%CATALINA_HOME%102 call "%CATALINA_HOME%\bin\setclasspath.bat" %1 103 if errorlevel 1 goto end 104 105 remAdd on extra jar files to CLASSPATH 106 if "%JSSE_HOME%" == "" gotonoJsse107 set CLASSPATH=%CLASSPATH%;%JSSE_HOME%\lib\jcert.jar;%JSSE_HOME%\lib\jnet.jar;%JSSE_HOME%\lib\jsse.jar108 :noJsse 109 set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\bootstrap.jar110 111 if not "%CATALINA_BASE%" == "" gotogotBase112 set CATALINA_BASE=%CATALINA_HOME%113 :gotBase 114 115 if not "%CATALINA_TMPDIR%" == "" gotogotTmpdir116 set CATALINA_TMPDIR=%CATALINA_BASE%\temp117 :gotTmpdir 118 119 if not exist "%CATALINA_BASE%\conf\logging.properties" gotonoJuli120 set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" 121 :noJuli 122 123 rem----- Execute The Requested Command --------------------------------------- 124 125 echoUsing CATALINA_BASE: %CATALINA_BASE%126 echoUsing CATALINA_HOME: %CATALINA_HOME%127 echoUsing CATALINA_TMPDIR: %CATALINA_TMPDIR%128 if ""%1"" == ""debug"" gotouse_jdk129 echoUsing JRE_HOME: %JRE_HOME%130 gotojava_dir_displayed131 :use_jdk 132 echoUsing JAVA_HOME: %JAVA_HOME%133 :java_dir_displayed 134 135 set _EXECJAVA=%_RUNJAVA%136 set MAINCLASS=org.apache.catalina.startup.Bootstrap137 set ACTION=start 138 set SECURITY_POLICY_FILE= 139 set DEBUG_OPTS= 140 set JPDA= 141 142 if not ""%1"" == ""jpda"" gotonoJpda143 set JPDA=jpda144 if not "%JPDA_TRANSPORT%" == "" gotogotJpdaTransport145 set JPDA_TRANSPORT=dt_shmem146 :gotJpdaTransport 147 if not "%JPDA_ADDRESS%" == "" gotogotJpdaAddress148 set JPDA_ADDRESS=jdbconn149 :gotJpdaAddress 150 if not "%JPDA_SUSPEND%" == "" gotogotJpdaSuspend151 set JPDA_SUSPEND=n152 :gotJpdaSuspend 153 if not "%JPDA_OPTS%" == "" gotogotJpdaOpts154 set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%155 :gotJpdaOpts 156 shift 157 :noJpda 158 159 if ""%1"" == ""debug"" gotodoDebug160 if ""%1"" == ""run"" gotodoRun161 if ""%1"" == ""start"" gotodoStart162 if ""%1"" == ""stop"" gotodoStop163 if ""%1"" == ""version"" gotodoVersion164 165 echo Usage: catalina ( commands ... ) 166 echocommands:167 echo debug StartCatalina in a debugger168 echo debug -security DebugCatalina with a security manager169 echo jpda start StartCatalina under JPDA debugger170 echo run StartCatalina in the current window171 echo run -security Startin the current window with security manager172 echo start StartCatalina in a separate window173 echo start -security Startin a separate window with security manager174 echostop Stop Catalina175 echoversion What version of tomcat are you running?176 goto end 177 178 :doDebug 179 shift 180 set _EXECJAVA=%_RUNJDB%181 set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java" 182 if not ""%1"" == ""-security"" gotoexecCmd183 shift 184 echoUsing Security Manager185 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy186 gotoexecCmd187 188 :doRun 189 shift 190 if not ""%1"" == ""-security"" gotoexecCmd191 shift 192 echoUsing Security Manager193 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy194 gotoexecCmd195 196 :doStart 197 shift 198 if not "%OS%" == "Windows_NT" gotonoTitle199 set _EXECJAVA=start "Tomcat"%_RUNJAVA%200 gotogotTitle201 :noTitle 202 set _EXECJAVA=start%_RUNJAVA%203 :gotTitle 204 if not ""%1"" == ""-security"" gotoexecCmd205 shift 206 echoUsing Security Manager207 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy208 gotoexecCmd209 210 :doStop 211 shift 212 set ACTION=stop213 set CATALINA_OPTS= 214 gotoexecCmd215 216 :doVersion 217 %_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo218 goto end 219 220 221 :execCmd 222 remGet remaining unshifted command line arguments and save them in the 223 set CMD_LINE_ARGS= 224 :setArgs 225 if ""%1""=="""" gotodoneSetArgs226 set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 227 shift 228 gotosetArgs229 :doneSetArgs 230 231 remExecute Java with the applicable properties 232 if not "%JPDA%" == "" gotodoJpda233 if not "%SECURITY_POLICY_FILE%" == "" gotodoSecurity234 %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%"%MAINCLASS% %CMD_LINE_ARGS% %ACTION%235 goto end 236 :doSecurity 237 %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%"%MAINCLASS% %CMD_LINE_ARGS% %ACTION%238 goto end 239 :doJpda 240 if not "%SECURITY_POLICY_FILE%" == "" gotodoSecurityJpda241 %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%"%MAINCLASS% %CMD_LINE_ARGS% %ACTION%242 goto end 243 :doSecurityJpda 244 %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%"%MAINCLASS% %CMD_LINE_ARGS% %ACTION%245 goto end 246 247 :end
以上最后的两个文件及前面有些配置使用该优化tomcat和jdk的,配置完成后的各个配置文件,具体操作步骤如下:
(1)负载均衡
找到Apache安装目录下conf目录中的httpd.conf文件。
在文件最后添加一句:include "D:\webserver\Apache Group\Apache2\conf\mod_jk.conf"(具体路径是你放置的位置而定)
接着在conf目录中新建文件mod_jk.conf并添加下面的内容:
#加载mod_jk Module
LoadModule jk_module modules/mod_jk-apache-2.0.59.so
#指定 workers.properties文件路径
JkWorkersFile conf/workers.properties
#指定哪些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器名
JkMount /*.jsp controller
在conf目录下新建workers.properties文件并添加如下内容:
#server
worker.list = controller
#========tomcat1========
worker.tomcat1.port=11009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 1
#========tomcat2========
worker.tomcat2.port=12009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1
#(解释一下AJP13是 Apache JServ Protocol version 1.3)
#========controller,负载均衡控制器========
worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2
worker.controller.sticky_session=1
将mod_jk-apache-2.0.59.so 复制到Apache的modules目录中。
接下来配置2个Tomcat
打开tomcat1\conf\ server.xml
将Server port 改为11005:<Server port="11005" shutdown="SHUTDOWN">
将Define Connector port改为11080:<Connector port="11080" maxHttpHeaderSize="8192"
将AJP13 Connector port改为11009:<Connector port="11009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
打开tomcat2\conf\server.xml
将Server port 改为12005:<Server port="12005" shutdown="SHUTDOWN">
将Define Connector port改为12080:<Connector port="12080" maxHttpHeaderSize="8192"
将AJP13 Connector port改为12009:<Connector port="12009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
好了,现在建立一个测试程序
分别在两个Tomcat的webapps中建立test目录,并新建test.jsp文件,内容如下:
<%
System.out.println("test");
%>
启动apache, tomcat1, tomcat2
访问http://localhost:8080/test/test.jsp (或者 http://localhost/test/test.jsp)不断刷新页面,看不到交替输出"test",你需要换两台机器或者开两个浏览器(即两个会话)这样可以在两个Tomcat的控制台中看到,交替输出"test", 这样就实现了负载均衡,由于没有开启session共享所以一次会话集中到了一个toamcat上多个会话会分配道不同的tomact中。
(2)集群配置
集群除了负载均衡,另一个主要功能是Session Replication。
打开tomcat1\conf\ server.xml将<Cluster>部分的注释去掉。
再打开tomcat2\conf\ server.xml将<Cluster>部分的注释也去掉,并将<Cluster>中<Receiver>的tcpListenPort的值改为4002。以避免与Tomcat1冲突。
分别在2个tomcat的webapps\test中新建WEB-INF目录,在WEB-INF中添加web.xml内容如下:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>TomcatDemo</display-name>
<distributable/>
</web-app>
主要是添加<distributable/>,distributable元素用来告诉servlet容器,程序将部署在分布式Web容器中。
重新启动tomcat1和tomcat2. 访问http://localhost:8080/test/test2.jsp (或http://localhost/test/test2.jsp)
随意添加key-value, 可以看到两个tomcat交替显示session中的值,各个tomcat的session是同步的。
再来修改tomcat1\conf\server.xml,找到<Engine name="Catalina" defaultHost="localhost">为其添加jvmRoute属性,值为apache的conf\workers.properties中配置的tomcat名字。<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
同样修改tomcat2\conf\server.xml的相同部分<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">jvmRoute是tomcat路由标示,由此区分两台tomcat主机。一次会话,就有一个sessionID,这个sessionID后面会跟上jvmRoute设置的值,这样一次会话,就只会让一个tomcat处理。
重新启动tomcat1, tomcat2
访问http://localhost:8080/test/test2.jsp 可以看到session.getId()的值在原session id后面多了jvmRoute的值。ID 46A5843FF4A1E0A84338225AC02F6430.tomcat1
随意添加key-value,可以看到session信息只在tomcat1中输出。
再打开一个浏览器,并访问http://localhost:8080/test/test2.jsp 其session id可能变为ID 11478E5BE5FE388E4845205B4133A30F.tomcat2
其值也只会在tomcat2中输出。
现在把tomcat1关闭,再次刷新访问tomcat1的那个浏览器,可以看到session信息输出到了tomcat2的控制台中,并且session信息仍然保留着。
2. Apache 2.2以后集成了mod_jk功能,相对于1.3版本,不需要再进行繁琐的worker.properties配置,配置过程大幅简化。
(1)apache的配置
a. 首先,在Apache安装目录下找到conf/httpd.conf文件,以文本编辑器打开。去掉以下文本前的注释符(#)以便让Apache在启动时自动加载代理(proxy)模块。
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
b. 向下拉动文档找到节点,在DirectoryIndex index.html后加上index.jsp,这一步只是为了待会配置完tomcat后能看到小猫首页,可以不做。
c. 继续下拉文档找到"Include conf/extra/httpd-vhosts.conf",去掉前面的注释符。
然后找到conf/extra/httpd-vhosts.conf文件,用文本编辑器打开conf/extra/httpd-vhosts.conf,配置虚拟站点,在最下面加上
<VirtualHost *:80> ServerAdmin 管理员邮箱 ServerName localhost(没有可用IP地址代替) ServerAlias localhost ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On ProxyPassReverse / balancer://cluster/ ErrorLog"logs/lbtest-error.log"CustomLog"logs/lbtest-access.log"common </VirtualHost>
d. 这里balancer://是告诉Apache需要进行负载均衡的代理,后面的cluster是集群名,可以随意取,两个日志引擎ErrorLog负责记录错误,CustomLog负责记录所有的http访问以及返回状态,日志名可以自己取,笔者取为lbtest。httpd-vhosts.conf配置完毕,回到httpd.conf,在文档最下面加上
ProxyRequests Off <proxy balancer://cluster> BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 BalancerMember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2 </proxy>
ProxyRequests Off 是告诉Apache需要使用反向代理(利用Apache进行负载均衡必须使用反向代理,用于配置工作在tomcat集群中的所有节点,这里的"cluster"必须与上面的集群名保持一致。
Apache通过ajp协议与tomcat进行通信,ip地址和端口唯一确定了tomcat节点和配置的ajp接受端口。loadfactor是负载因子,Apache会按负载因子的比例向后端tomcat节点转发请求,负载因子越大,对应的tomcat服务器就会处理越多的请求,如两个tomcat都是1,Apache就按1:1的比例转发,如果是2和1就按2:1的比例转发。route参数对应后续tomcat配置中的引擎路径(jvmRoute)。
重启Apache服务,如果此时访问http://localhost/将会返回503错误,打开刚才配置的错误日志logs/lbtest-error.log,可以看到错误原因是因为后台服务器没有响应,因为此时tomcat尚未配置和启动。
(2)tomcat配置
如果仅仅为了配置一个可用的集群,Tomcat的配置将会非常简单。分别打开t1和t2的server.xml配置文件,对于t1,尽量采用默认的设置,而对t2作较大改动以避免与t1冲突。如果t2和t1不在同一台服务器上运行,对于端口就不需做改动。
a. 首先是配置关闭端口,找到,t1不变,把t2改为9005。
b. 下面配置Connector的端口,找到non-SSL HTTP/1.1 Connector,即tomcat单独工作时的默认Connector,保留t1默认配置,在8080端口侦听,而把t2设置为在9080端口侦听。
c. 往下找到AJP 1.3 Connector,<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />,这是tomcat接收从Apache过来的ajp连接请求时使用的端口,保留t1默认设置,把t2端口改为9009。注意,这里的端口对应Apache httpd.conf中BalancerMember中配置的ajp连接端口。
d. 继续向下配置引擎,找到<Engine name="Catalina" defaultHost="localhost">,去掉这段或改为注释,把上方紧挨的<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">注释符去掉,对于t2,去掉注释符并把jvm1改为jvm2。这里的jvmRoute对应Apache httpd.conf中BalancerMember中配置的route参数。
e. 向下找到<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>,打开注释,这里的配置是为了可以在集群中的所有tomcat节点间共享会话(Session)。如果仅仅为了获得一个可用的tomcat集群,Cluster只需要这么配置就可以了,对于更多的Cluster配置笔者将另文解释。
server.xml的配置修改完毕,下一步需要对具体的应用进行配置。在webapps目录下新建test目录,在test目录下新建test.jsp文件,代码如下:
1 ?<%@ page contentType="text/html; charset=GBK" %> 2 <%@ page import="java.util.*" %> 3 <html> 4 <head> 5 <title>Cluster App Test</title> 6 </head> 7 <body> 8 Server Info:9 <%out.println(request.getLocalAddr()+ ":" +request.getLocalPort()+"<br>");%> 10 <%out.println("<br> ID" +session.getId()+"<br>");11 StringdataName=request.getParameter("dataName");12 if(dataName != null &&dataName.length()> 0) {13 StringdataValue=request.getParameter("dataValue");14 session.setAttribute(dataName, dataValue);15 }16 out.print("<b>Session 列表</b>");17 Enumeration e=session.getAttributeNames();18 while(e.hasMoreElements()) {19 Stringname=(String)e.nextElement();20 Stringvalue=session.getAttribute(name).toString();21 out.println( name+ "=" +value+"<br>");22 System.out.println( name+ "=" +value);23 }24 %> 25 <formaction="test.jsp"method="POST"> 26 名称:<inputtype=textsize=20name="dataName"><br/> 27 值:<inputtype=textsize=20name="dataValue"><br/> 28 <inputtype=submit/> 29 </form> 30 </body> 31 </html>
f. 在test目录下继续新建WEB-INF目录和web.xml,在<web-app>节点下加入<distributable />,这一步非常重要,是为了通知tomcat服务器,当前应用需要在集群中的所有节点间实现Session共享。如果tomcat中的所有应用都需要Session共享,也可以把conf/context.xml中的<Context>改为<Context distributable="true">,这样就不需对所有应用的web.xml再进行单独配置(修改需要Session复制的应用中WEB-INF/web.xml文件,在文件中的<web-app>标签中增加:<distributable/>在应用的web.xml中增加上述配置后,就表示该应用需要进行Session复制)。
启动t1,待t1启动完成后再启动t2。再次访问http://localhost,可以看到小猫页面。访问http://localhost/test/test.jsp。可以看到包括服务器地址,端口,sessionid等信息在内的页面。
注意这里的sessionid,与平常的sessionid相比多了小数点和后面的部分,这里的jvm1即处理当前请求tomcat服务器的jvmRoute,通过这里可以知道是集群中的哪一个服务器处理了当前请求。在文本框中输入名称和值,点击按钮,信息就保存到了Session中,并且显示到页面上。不断点击按钮,可以发现输入的信息并未丢失,而且sessionid小数点之前的部分保持不变,而小数点后面的字符不停的变化,表明是由不同的tomcat服务器处理了这些请求。这样就实现了负载均衡,并且集群中的不同节点间可以实现会话的共享。此时如果停止一个tomcat服务器t2,Apache将会自动把后续请求转发到集群中的其他服务器即t1。重启t2后,Apache会自动侦测到t2的状态为可用,然后会继续在t1和t2间进行负载均衡。
如果需要向集群中增加节点,首先需要对tomcat作类似配置,然后修改Apache httpd.conf,增加BalancerMember,指向新增的tomcat即可。
转载于:https://www.cnblogs.com/jice/archive/2012/04/17/2410417.html
windows下tomcat集群配置(两种方法)相关推荐
- Windows下Redis集群配置
目录 一.准备材料 二.主从模式 三.哨兵模式 四.其他 采用一主(master)二从(slave)三哨兵(sentinel)的架构模式构建最简单的Redis集群 服务类型 是否主服务器 IP地址 端 ...
- tomcat修改jdk配置两种方法
由于一个电脑多个项目,可能会使用多个版本的jdk,所以在跑tomcat的时候,可以自定义配置的各项目所使用的jdk 配置步骤(window设置): 1. 在catalina.bat找到如下代码: ec ...
- Nginx以及通过Nginx实现tomcat集群配置与负载均衡
Nginx简介 启动,停止,和重新加载配置文件命令 Nginx功能 正向代理和反向代理的区别 反向代理 负载均衡 1.RR(默认) 2.权重 3.ip_hash 4.fair(第三方) 5.url_h ...
- window xp Apache与Tomcat集群配置--转载
转载地址:http://www.cnblogs.com/obullxl/archive/2011/06/09/apache-tomcat-cluster-config.html 一. 环境说明 Win ...
- Apache + Tomcat集群配置详解(1)
Apache + Tomcat集群配置详解(1) 一.软件准备 Apache 2.2 : http://httpd.apache.org/download.cgi,下载msi安装程序,选择no ssl ...
- Windows下Kafka集群搭建
一.Windows下Zookeeper集群搭建. 1.集群版本:2.8.1,3.0版本不再支持JDK8,不在需要Zookeeper. 2.Zookeeper版本:3.8.0. 3.Zookeeper三 ...
- CentOS下torque集群配置(一)-torque安装与配置
CentOS下torque集群配置(一)-torque安装与配置 一.Centos7系统的安装及设置 1.给两台电脑安装CentOS7.0,光盘启动路径修改为:/dev/cdrom 修改主机名称 # ...
- Nginx+Memcached+Tomcat集群配置实践(Sticky Session)
准备工作 创建一个简单的web应用,名为session.其中有两个页面,分别如下所示: 页面login.jsp [html] view plaincopy <%@ page language=& ...
- 大数据互联网架构 tomcat集群配置时三个端口的作用
tomcat集群配置时三个端口的作用 在配置多个tomcat时需要同时配置这三个端口 Connector用于监听请求 protocol: http/1.1协议 , 用于监听浏览器发送的请求 , 设置成 ...
最新文章
- 想成为软件架构师,你的举止够优雅吗?
- mysql 日期减法_日期格式处理的几种方法
- slf4j + logback 输出日志:mybatis sql语句
- 神经网络的分类准确率是100%到底意味着什么?
- 将js文件打包进dll 方法3
- python处理进度条
- 基于mysql数据库的应用_MySQL数据库应用
- nodemanager_如何使用NodeManager来控制WebLogic Server
- java修改pdf内容流_java – 在PDFBox中,如何更改PDRectangle对象的原点(0,0)?
- 怎样验证软件是否可信?是否被篡改?
- 第11章 数据库安全性
- javascript数据结构与算法 --- 高级排序算法
- java zk_zk框架:zul文件,纯Java或混合更好的性能
- 多领域中文语音识别数据集 WenetSpeech 正式发布——有效下载教程
- html 游戏 消消乐,html5叠房子消消乐小游戏代码
- stm8s定时器输出比较模式
- Android实现记账本(麻雀虽小,五脏俱全)
- item_password-获得淘口令真实url接口,淘宝app短链接商品接口,1688商品淘口令url接口
- R语言快速读写与矩阵运算
- mysql怎么禁用安全模式_mysql开启和关闭安全模式