• 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)

    mod_jk.conf 
     1 # 加载mod_jk模块,此处的mod_jk.so为你复制到modules/下的mod_jk名   
     2 LoadModule jk_module modules/mod_jk-apache-2.2.2.so
     3 # 指定 workers.properties文件路径(指定tomcat监听配置文件地址
     4 JkWorkersFile conf/workers.properties
     5 # 设置日志存放路径   
     6 JkLogFile logs/mod_jk.log
     7 # 设置日志级别 [debug/error/info]   
     8 JkLogLevel info   
     9 # 设置日志格式   
    10 JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"  
    11 # JkOptions indicate to send SSL KEY SIZE,   
    12 JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories   
    13 # JkRequestLogFormat set the request format   
    14 JkRequestLogFormat "%w %V %T"  
    15 
    16 #设置虚拟主机
    17 #<VirtualHost localhost>
    18 #如果非虚拟主机,将<VirtualHost localhost>和最后的</VirtualHost>注释或者删除掉即可
    19 #ServerAdmin localhost
    20 #DocumentRoot E:/wwwroot
    21 #<Directory "E:/wwwroot">
    22 #您的站点项目所在路径,应与tomcat中的目录设置相同,据说以上两个必须同时设置才可以生效,没有试过不同的时候会有什么情况
    23 #ServerName localhost
    24 #DirectoryIndex index.html index.htm index.jsp
    25 #ErrorLog logs/shsc-error_log.txt
    26 #CustomLog logs/shsc-access_log.txt common
    27 #JkMount /servlet/* ajp13 
    28 #让Apache支持对servlet传送,用以Tomcat解析
    29 #JkMount /*.jsp ajp13 
    30 #让Apache支持对jsp传送,用以Tomcat解析
    31 #JkMount /*.do ajp13 
    32 #让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 controller
    37 JkMount /*.do controller 
    38 JkMount /*.dd controller
    39 JkMount /*.ee controller
    40 JkMount /servlet/* controller
    41 JkMount /gwyhr* controller

                      2>httpd.conf(apache/conf)

    httpd.conf
      1 #
      2 # This is the main Apache HTTP server configuration file.  It contains the
      3 # configuration directives that give the server its instructions.
      4 # See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
      5 # In particular, see 
      6 # <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 understanding
     10 # what they do.  They're here only as hints or reminders.  If you are unsure
     11 # consult the online docs. You have been warned.  
     12 #
     13 # Configuration and logfile names: If the filenames you specify for many
     14 # of the server's control files begin with "/" (or "drive:/" for Win32), the
     15 # server will use that explicit path.  If the filenames do *not* begin
     16 # 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 the
     18 # server as "D:/Program Files/Apache Software Foundation/Apache2.2/logs/foo.log".
     19 #
     20 # NOTE: Where filenames are specified, you must use forward slashes
     21 # 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 located
     23 # will be used by default.  It is recommended that you always supply
     24 # an explicit drive letter in absolute paths to avoid confusion.
     25 
     26 #
     27 # ServerRoot: The top of the directory tree under which the server's
     28 # configuration, error, and log files are kept.
     29 #
     30 # Do not add a slash at the end of the directory path.  If you point
     31 # ServerRoot at a non-local disk, be sure to point the LockFile directive
     32 # at a local disk.  If you wish to share the same ServerRoot for multiple
     33 # 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/or
     39 # ports, instead of the default. See also the <VirtualHost>
     40 # directive.
     41 #
     42 # Change this to Listen on specific IP addresses as shown below to 
     43 # 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) Support
     50 #
     51 # To be able to use the functionality of a module which was built as a DSO you
     52 # have to place corresponding `LoadModule' lines at this location so the
     53 # directives contained in it are actually available _before_ they are used.
     54 # Statically compiled modules (those listed by `httpd -l') do not need
     55 # to be loaded here.
     56 #
     57 # Example:
     58 # LoadModule foo_module modules/mod_foo.so
     59 #
     60 LoadModule actions_module modules/mod_actions.so
     61 LoadModule alias_module modules/mod_alias.so
     62 LoadModule asis_module modules/mod_asis.so
     63 LoadModule auth_basic_module modules/mod_auth_basic.so
     64 #LoadModule auth_digest_module modules/mod_auth_digest.so
     65 #LoadModule authn_alias_module modules/mod_authn_alias.so
     66 #LoadModule authn_anon_module modules/mod_authn_anon.so
     67 #LoadModule authn_dbd_module modules/mod_authn_dbd.so
     68 #LoadModule authn_dbm_module modules/mod_authn_dbm.so
     69 LoadModule authn_default_module modules/mod_authn_default.so
     70 LoadModule authn_file_module modules/mod_authn_file.so
     71 #LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
     72 #LoadModule authz_dbm_module modules/mod_authz_dbm.so
     73 LoadModule authz_default_module modules/mod_authz_default.so
     74 LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
     75 LoadModule authz_host_module modules/mod_authz_host.so
     76 #LoadModule authz_owner_module modules/mod_authz_owner.so
     77 LoadModule authz_user_module modules/mod_authz_user.so
     78 LoadModule autoindex_module modules/mod_autoindex.so
     79 #LoadModule cache_module modules/mod_cache.so
     80 #LoadModule cern_meta_module modules/mod_cern_meta.so
     81 LoadModule cgi_module modules/mod_cgi.so
     82 #LoadModule charset_lite_module modules/mod_charset_lite.so
     83 #LoadModule dav_module modules/mod_dav.so
     84 #LoadModule dav_fs_module modules/mod_dav_fs.so
     85 #LoadModule dav_lock_module modules/mod_dav_lock.so
     86 #LoadModule dbd_module modules/mod_dbd.so
     87 
     88 ######apache启用gzip压缩######
     89 #加载mod_deflate.so模块
     90 LoadModule deflate_module modules/mod_deflate.so
     91 #对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/javascript
     93 #压缩级别 9 性能最佳
     94 DeflateCompressionLevel 9
     95 #启用deflate模块对本站点的所有输出进行GZIP压缩
     96 SetOutputFilter DEFLATE
     97 #############################
     98 
     99 LoadModule dir_module modules/mod_dir.so
    100 #LoadModule disk_cache_module modules/mod_disk_cache.so
    101 #LoadModule dumpio_module modules/mod_dumpio.so
    102 LoadModule env_module modules/mod_env.so
    103 #LoadModule expires_module modules/mod_expires.so
    104 #LoadModule ext_filter_module modules/mod_ext_filter.so
    105 #LoadModule file_cache_module modules/mod_file_cache.so
    106 #LoadModule filter_module modules/mod_filter.so
    107 #LoadModule headers_module modules/mod_headers.so
    108 #LoadModule ident_module modules/mod_ident.so
    109 #LoadModule imagemap_module modules/mod_imagemap.so
    110 LoadModule include_module modules/mod_include.so
    111 #LoadModule info_module modules/mod_info.so
    112 LoadModule isapi_module modules/mod_isapi.so
    113 #LoadModule ldap_module modules/mod_ldap.so
    114 #LoadModule logio_module modules/mod_logio.so
    115 LoadModule log_config_module modules/mod_log_config.so
    116 #LoadModule log_forensic_module modules/mod_log_forensic.so
    117 #LoadModule mem_cache_module modules/mod_mem_cache.so
    118 LoadModule mime_module modules/mod_mime.so
    119 #LoadModule mime_magic_module modules/mod_mime_magic.so
    120 LoadModule negotiation_module modules/mod_negotiation.so
    121 #LoadModule proxy_module modules/mod_proxy.so
    122 #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    123 #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    124 #LoadModule proxy_connect_module modules/mod_proxy_connect.so
    125 #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    126 #LoadModule proxy_http_module modules/mod_proxy_http.so
    127 #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
    128 #LoadModule reqtimeout_module modules/mod_reqtimeout.so
    129 #LoadModule rewrite_module modules/mod_rewrite.so
    130 LoadModule setenvif_module modules/mod_setenvif.so
    131 #LoadModule speling_module modules/mod_speling.so
    132 #LoadModule ssl_module modules/mod_ssl.so
    133 #LoadModule status_module modules/mod_status.so
    134 #LoadModule substitute_module modules/mod_substitute.so
    135 #LoadModule unique_id_module modules/mod_unique_id.so
    136 #LoadModule userdir_module modules/mod_userdir.so
    137 #LoadModule usertrack_module modules/mod_usertrack.so
    138 #LoadModule version_module modules/mod_version.so
    139 #LoadModule vhost_alias_module modules/mod_vhost_alias.so
    140 
    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 run
    145 # 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 for
    149 # running httpd, as with most system services.
    150 #
    151 User daemon
    152 Group daemon
    153 
    154 </IfModule>
    155 </IfModule>
    156 
    157 # 'Main' server configuration
    158 #
    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 a
    161 # <VirtualHost> definition.  These values also provide defaults for
    162 # 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 the
    166 # virtual host being defined.
    167 #
    168 
    169 #
    170 # ServerAdmin: Your address, where problems with the server should be
    171 # e-mailed.  This address appears on some server-generated pages, such
    172 # as error documents.  e.g. admin@your-domain.com
    173 #
    174 ServerAdmin zbjbox@gmail.com
    175 
    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 specify
    179 # 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 your
    187 # documents. By default, all requests are taken from this directory, but
    188 # 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 respect
    194 # to which services and features are allowed and/or disabled in that
    195 # directory (and its subdirectories). 
    196 #
    197 # First, we configure the "default" to be a very restrictive set of 
    198 # features.  
    199 #
    200 <Directory />
    201     Options FollowSymLinks
    202     AllowOverride None
    203     Order deny,allow
    204     Deny from all
    205 </Directory>
    206 
    207 #
    208 # Note that from this point forward you must specifically allow
    209 # particular features to be enabled - so if something's not working as
    210 # you might expect, make sure that you have specifically enabled it
    211 # 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 MultiViews
    222     #
    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 see
    227     # http://httpd.apache.org/docs/2.2/mod/core.html#options
    228     # for more information.
    229     #
    230     Options Indexes FollowSymLinks
    231 
    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 Limit
    236     #
    237     AllowOverride None
    238 
    239     #
    240     # Controls who can get stuff from this server.
    241     #
    242     Order allow,deny
    243     Allow from all
    244 
    245 </Directory>
    246 
    247 #
    248 # DirectoryIndex: sets the file that Apache will serve if a directory
    249 # is requested.
    250 # 此处加上index.jsp是为了配置完tomcat后若apache中的index.html不存在则能看到tomcat的首页(可以不加,则看到的是it works)
    251 #
    252 <IfModule dir_module>
    253     DirectoryIndex index.html index.jsp
    254 </IfModule>
    255 
    256 #
    257 # The following lines prevent .htaccess and .htpasswd files from being 
    258 # viewed by Web clients. 
    259 #
    260 <FilesMatch "^\.ht">
    261     Order allow,deny
    262     Deny from all
    263     Satisfy All
    264 </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 be
    270 # 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 warn
    281 
    282 <IfModule log_config_module>
    283     #
    284     # The following directives define some format nicknames for use with
    285     # a CustomLog directive (see below).
    286     #
    287     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    288     LogFormat "%h %l %u %t \"%r\" %>s %b" common
    289 
    290     <IfModule logio_module>
    291       # You need to enable mod_logio.c to use %I and %O
    292       LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    293     </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 be
    300     # logged therein and *not* in this file.
    301     #
    302     CustomLog "logs/access.log" common
    303 
    304     #
    305     # If you prefer a logfile with access, agent, and referer information
    306     # (Combined Logfile Format) you can use the following directive.
    307     #
    308     #CustomLog "logs/access.log" combined
    309 </IfModule>
    
    310 
    311 <IfModule alias_module>
    312     #
    313     # Redirect: Allows you to tell clients about documents that used to 
    314     # exist in your server's namespace, but do not anymore. The client 
    315     # will make a new request for the document at its new location.
    316     # Example:
    317     # Redirect permanent /foo http://localhost/bar
    318 
    319     #
    320     # Alias: Maps web paths into filesystem paths and is used to
    321     # access content that does not live under the DocumentRoot.
    322     # Example:
    323     # Alias /webpath /full/filesystem/path
    324     #
    325     # If you include a trailing / on /webpath then the server will
    326     # require it to be present in the URL.  You will also likely
    327     # need to provide a <Directory> section to allow access to
    328     # the filesystem path.
    329 
    330     #
    331     # ScriptAlias: This controls which directories contain server scripts. 
    332     # ScriptAliases are essentially the same as Aliases, except that
    333     # documents in the target directory are treated as applications and
    334     # run by the server when requested rather than as documents sent to the
    335     # client.  The same rules about trailing "/" apply to ScriptAlias
    336     # 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 UNIX
    345     # socket used to communicate with the CGI daemon of mod_cgid.
    346     #
    347     #Scriptsock logs/cgisock
    348 </IfModule>
    349 
    350 #
    351 # "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased
    352 # CGI directory exists, if you have that configured.
    353 #
    354 <Directory "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
    355     AllowOverride None
    356     Options None
    357     Order allow,deny
    358     Allow from all
    359 </Directory>
    360 
    361 #
    362 # DefaultType: the default MIME type the server will use for a document
    363 # if it cannot otherwise determine one, such as from filename extensions.
    364 # If your server contains mostly text or HTML documents, "text/plain" is
    365 # a good value.  If most of your content is binary, such as applications
    366 # or images, you may want to use "application/octet-stream" instead to
    367 # keep browsers from trying to display binary files as though they are
    368 # text.
    369 #
    370 DefaultType text/plain
    371 
    372 <IfModule mime_module>
    373     #
    374     # TypesConfig points to the file containing the list of mappings from
    375     # filename extension to MIME-type.
    376     #
    377     TypesConfig conf/mime.types
    378 
    379     #
    380     # AddType allows you to add to or override the MIME configuration
    381     # file specified in TypesConfig for specific file types.
    382     #
    383     #AddType application/x-gzip .tgz
    384     #
    385     # AddEncoding allows you to have certain browsers uncompress
    386     # information on the fly. Note: Not all browsers support this.
    387     #
    388     #AddEncoding x-compress .Z
    389     #AddEncoding x-gzip .gz .tgz
    390     #
    391     # If the AddEncoding directives above are commented-out, then you
    392     # probably should define those extensions to indicate media types:
    393     #
    394     AddType application/x-compress .Z
    395     AddType application/x-gzip .gz .tgz
    396 
    397     #
    398     # AddHandler allows you to map certain file extensions to "handlers":
    399     # actions unrelated to filetype. These can be either built into the server
    400     # 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 .cgi
    406 
    407     # For type maps (negotiated resources):
    408     #AddHandler type-map var
    409 
    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 .shtml
    417     #AddOutputFilter INCLUDES .shtml
    418 </IfModule>
    419 
    420 #
    421 # The mod_mime_magic module allows the server to use various hints from the
    422 # contents of the file itself to determine its type.  The MIMEMagicFile
    423 # directive tells the module where the hint definitions are located.
    424 #
    425 #MIMEMagicFile conf/magic
    426 
    427 #
    428 # Customizable error responses come in three flavors:
    429 # 1) plain text 2) local redirects 3) external redirects
    430 #
    431 # Some examples:
    432 #ErrorDocument 500 "The server made a boo boo."
    433 #ErrorDocument 404 /missing.html
    434 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
    435 #ErrorDocument 402 http://localhost/subscription_info.html
    436 #
    437 
    438 #
    439 # MaxRanges: Maximum number of Ranges in a request before
    440 # returning the entire resource, or one of the special
    441 # values 'default', 'none' or 'unlimited'.
    442 # Default setting is to accept 200 Ranges.
    443 #MaxRanges unlimited
    444 
    445 #
    446 # EnableMMAP and EnableSendfile: On systems that support it, 
    447 # memory-mapping or the sendfile syscall is used to deliver
    448 # files.  This usually improves server performance, but must
    449 # be turned off when serving from networked-mounted 
    450 # filesystems or if support for these functions is otherwise
    451 # broken on your system.
    452 #
    453 #EnableMMAP off
    454 #EnableSendfile off
    455 
    456 # Supplemental configuration
    457 #
    458 # The configuration files in the conf/extra/ directory can be 
    459 # included to add extra features or to modify the default configuration of 
    460 # the server, or you may simply copy their contents here and change as 
    461 # necessary.
    462 
    463 # Server-pool management (MPM specific)
    464 #Include conf/extra/httpd-mpm.conf
    465 
    466 # Multi-language error messages
    467 #Include conf/extra/httpd-multilang-errordoc.conf
    468 
    469 # Fancy directory listings
    470 #Include conf/extra/httpd-autoindex.conf
    471 
    472 # Language settings
    473 #Include conf/extra/httpd-languages.conf
    474 
    475 # User home directories
    476 #Include conf/extra/httpd-userdir.conf
    477 
    478 # Real-time info on requests and configuration
    479 #Include conf/extra/httpd-info.conf
    480 
    481 # Virtual hosts
    482 #Include conf/extra/httpd-vhosts.conf
    483 
    484 # Local access to the Apache HTTP Server Manual
    485 #Include conf/extra/httpd-manual.conf
    486 
    487 # Distributed authoring and versioning (WebDAV)
    488 #Include conf/extra/httpd-dav.conf
    489 
    490 # Various default settings
    491 #Include conf/extra/httpd-default.conf
    492 
    493 # Secure (SSL/TLS) connections
    494 #Include conf/extra/httpd-ssl.conf
    495 #
    496 # Note: The following must must be present to support
    497 #       starting without SSL on platforms with no /dev/random equivalent
    498 #       but a statically compiled-in mod_ssl.
    499 #
    500 <IfModule ssl_module>
    501 SSLRandomSeed startup builtin
    502 SSLRandomSeed connect builtin
    503 </IfModule>
    504 include conf/mod_jk.conf

                      3>workers.properties(apache/conf)

    workers.properties
     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\jre
     3 #ps=\
     4 #worker.list=ajp13
     5 #worker.ajp13.port=8009
     6 #worker.ajp13.host=localhost
     7 #worker.ajp13.type=ajp13
     8 #worker.ajp13.lbfactor=1
     9 #tomcat的路径,让mod_jk模块知道
    10 workers.tomcat1_home=D:\Program Files\Apache Software Foundation\tomcat1
    11 workers.tomcat2_home=D:\Program Files\Apache Software Foundation\tomcat2
    12 workers.tomcat3_home=D:\Program Files\Apache Software Foundation\tomcat3
    13 #jdk的路径,让mod_jk模块知道jre的位置
    14 workers.java_home=C:\Program Files\Java\jdk1.6.0_18\jre
    15 #路径分隔符
    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配置,默认8009
    26 worker.tomcat2.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址
    27 worker.tomcat2.type=ajp13
    28 worker.tomcat2.lbfactor = 1 #server的加权比重,值越高,分得的请求越多
    29 #========tomcat3========
    30 worker.tomcat3.port=9010 #ajp13 端口号,在tomcat下server.xml配置,默认8009
    31 worker.tomcat3.host=localhost #tomcat的主机地址,如不为本机,请填写ip地址
    32 worker.tomcat3.type=ajp13
    33 worker.tomcat3.lbfactor = 1 #server的加权比重,值越高,分得的请求越多
    34 #========controller,负载均衡控制器========
    35 worker.controller.type=lb
    36 worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3 #指定分担请求的tomcat
    37 worker.controller.sticky_session=False #粘性会话设置

              (2)tomcat配置

          1>server.xml(tomcat/conf)

    server.xml
      1 <?xml version='1.0' encoding='utf-8'?>
      2 <!--
      3   Licensed to the Apache Software Foundation (ASF) under one or more
      4   contributor license agreements.  See the NOTICE file distributed with
      5   this work for additional information regarding copyright ownership.
      6   The ASF licenses this file to You under the Apache License, Version 2.0
      7   (the "License"); you may not use this file except in compliance with
      8   the License.  You may obtain a copy of the License at
      9 
     10       http://www.apache.org/licenses/LICENSE-2.0
     11 
     12   Unless required by applicable law or agreed to in writing, software
     13   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 and
     16   limitations under the License.
     17 -->
     18 <!-- Note:  A "Server" is not itself a "Container", so you may not
     19      define subcomponents such as "Valves" at this level.
     20      Documentation at /docs/config/server.html
     21  -->
     22 <Server port="8005" shutdown="SHUTDOWN">
     23 
     24   <!--APR library loader. Documentation at /docs/apr.html -->
     25   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
     26   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
     27   <Listener className="org.apache.catalina.core.JasperListener" />
     28   <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
     29   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
     30   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
     31 
     32   <!-- Global JNDI resources
     33        Documentation at /docs/jndi-resources-howto.html
     34   -->
     35   <GlobalNamingResources>
     36     <!-- Editable user database that can also be used by
     37          UserDatabaseRealm to authenticate users
     38     -->
     39     <Resource name="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 share
     47        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.html
     50    -->
     51   <Service name="Catalina">
     52   
     53     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
     54     <!--executor-->
     55     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
     56         maxThreads="1000" minSpareThreads="350"/>
     57     
     58     
     59     <!-- A "Connector" represents an endpoint by which requests are received
     60          and responses are returned. Documentation at :
     61          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     62          Java AJP  Connector: /docs/config/ajp.html
     63          APR (HTTP/AJP) Connector: /docs/apr.html
     64          Define a non-SSL HTTP/1.1 Connector on port 8080
     65     -->
     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     <Connector executor="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 8443
    102          This connector uses the JSSE configuration, when using APR, the 
    103          connector should be using the OpenSSL style configuration
    104          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     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    113 
    114 
    115     <!-- An Engine represents the entry point (within Catalina) that processes
    116          every request.  The Engine implementation for Tomcat stand alone
    117          analyzes the HTTP headers included with the request, and passes them
    118          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     <Engine name="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       <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
    133                  channelSendOptions="6">
    134 
    135           <Manager className="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           <Channel className="org.apache.catalina.tribes.group.GroupChannel">
    145             <Membership className="org.apache.catalina.tribes.membership.McastService"
    146                         address="228.0.0.4"
    147                         port="45564"
    148                         frequency="500"
    149                         dropTime="3000"/>
    150             <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
    151                       address="auto"
    152                       port="5000"
    153                       selectorTimeout="100"
    154                       maxThreads="6"/>
    155 
    156             <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
    157               <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
    158             </Sender>
    159             <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
    160             <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
    161             <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
    162           </Channel>
    163 
    164           <Valve className="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           <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
    176       </Cluster>
    177       
    178       <!-- The request dumper valve dumps useful debugging information about
    179            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 JNDI
    186            resources under the key "UserDatabase".  Any edits
    187            that are performed against this UserDatabase are immediately
    188            available for use by the Realm.  -->
    189       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    190              resourceName="UserDatabase"/>
    191 
    192       <!-- Define the default virtual host
    193            Note: XML Schema validation will not work with Xerces 2.2.
    194        -->
    195       <Host name="localhost"  appBase="webapps"
    196             unpackWARs="true" autoDeploy="true"
    197             xmlValidation="false" xmlNamespaceAware="false">
    198 
    199         <!-- SingleSignOn valve, share authentication between web applications
    200              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)

    web.xml(tomcat下的)
    <?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-app xmlns="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内存优化配置的更改(前两行)

    catalina.bat
      1 set CATALINA_OPTS=-Xms256m -Xmx256m 
      2 set JAVA_OPTS=-Xms256m -Xmx256m
      3 @echo off
      4 rem Licensed to the Apache Software Foundation (ASF) under one or more
      5 rem contributor license agreements.  See the NOTICE file distributed with
      6 rem this work for additional information regarding copyright ownership.
      7 rem The 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 rem the License.  You may obtain a copy of the License at
     10 rem
     11 rem     http://www.apache.org/licenses/LICENSE-2.0
     12 rem
     13 rem Unless required by applicable law or agreed to in writing, software
     14 rem distributed under the License is distributed on an "AS IS" BASIS,
     15 rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 rem See the License for the specific language governing permissions and
     17 rem limitations under the License.
     18 
     19 if "%OS%" == "Windows_NT" setlocal
     20 rem ---------------------------------------------------------------------------
     21 rem Start/Stop Script for the CATALINA Server
     22 rem
     23 rem Environment Variable Prequisites
     24 rem
     25 rem   CATALINA_HOME   May point at your Catalina "build" directory.
     26 rem
     27 rem   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
     28 rem                   of a Catalina installation.  If not present, resolves to
     29 rem                   the same directory that CATALINA_HOME points to.
     30 rem
     31 rem   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
     32 rem                   or "run" command is executed.
     33 rem
     34 rem   CATALINA_TMPDIR (Optional) Directory path location of temporary directory
     35 rem                   the JVM should use (java.io.tmpdir).  Defaults to
     36 rem                   %CATALINA_BASE%\temp.
     37 rem
     38 rem   JAVA_HOME       Must point at your Java Development Kit installation.
     39 rem                   Required to run the with the "debug" argument.
     40 rem
     41 rem   JRE_HOME        Must point at your Java Runtime installation.
     42 rem                   Defaults to JAVA_HOME if empty.
     43 rem
     44 rem   JAVA_OPTS       (Optional) Java runtime options used when the "start",
     45 rem                   "stop", or "run" command is executed.
     46 rem
     47 rem   JSSE_HOME       (Optional) May point at your Java Secure Sockets Extension
     48 rem                   (JSSE) installation, whose JAR files will be added to the
     49 rem                   system class path used to start Tomcat.
     50 rem
     51 rem   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"
     52 rem                   command is executed. The default is "dt_shmem".
     53 rem
     54 rem   JPDA_ADDRESS    (Optional) Java runtime options used when the "jpda start"
     55 rem                   command is executed. The default is "jdbconn".
     56 rem
     57 rem   JPDA_SUSPEND    (Optional) Java runtime options used when the "jpda start"
     58 rem                   command is executed. Specifies whether JVM should suspend
     59 rem                   execution immediately after startup. Default is "n".
     60 rem
     61 rem   JPDA_OPTS       (Optional) Java runtime options used when the "jpda start"
     62 rem                   command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,
     63 rem                   and JPDA_SUSPEND are ignored. Thus, all required jpda
     64 rem                   options MUST be specified. The default is:
     65 rem
     66 rem                   -Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,
     67 rem                       address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%
     68 rem
     69 rem $Id: catalina.bat 656834 2008-05-15 21:04:04Z markt $
     70 rem ---------------------------------------------------------------------------
     71 
     72 rem Guess CATALINA_HOME if not defined
     73 set CURRENT_DIR=%cd%
     74 if not "%CATALINA_HOME%" == "" goto gotHome
     75 set CATALINA_HOME=%CURRENT_DIR%
     76 if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
     77 cd ..
     78 set CATALINA_HOME=%cd%
     79 cd %CURRENT_DIR%
     80 :gotHome
     81 if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
     82 echo The CATALINA_HOME environment variable is not defined correctly
     83 echo This environment variable is needed to run this program
     84 goto end
     85 :okHome
     86 
     87 rem Get standard environment variables
     88 if "%CATALINA_BASE%" == "" goto gotSetenvHome
     89 if exist "%CATALINA_BASE%\bin\setenv.bat" call "%CATALINA_BASE%\bin\setenv.bat"
     90 goto gotSetenvBase
     91 :gotSetenvHome
     92 if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
     93 :gotSetenvBase
     94 
     95 rem Get standard Java environment variables
     96 if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath
     97 echo Cannot find %CATALINA_HOME%\bin\setclasspath.bat
     98 echo This file is needed to run this program
     99 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 rem Add on extra jar files to CLASSPATH
    106 if "%JSSE_HOME%" == "" goto noJsse
    107 set CLASSPATH=%CLASSPATH%;%JSSE_HOME%\lib\jcert.jar;%JSSE_HOME%\lib\jnet.jar;%JSSE_HOME%\lib\jsse.jar
    108 :noJsse
    109 set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\bootstrap.jar
    110 
    111 if not "%CATALINA_BASE%" == "" goto gotBase
    112 set CATALINA_BASE=%CATALINA_HOME%
    113 :gotBase
    114 
    115 if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir
    116 set CATALINA_TMPDIR=%CATALINA_BASE%\temp
    117 :gotTmpdir
    118 
    119 if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuli
    120 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 echo Using CATALINA_BASE:   %CATALINA_BASE%
    126 echo Using CATALINA_HOME:   %CATALINA_HOME%
    127 echo Using CATALINA_TMPDIR: %CATALINA_TMPDIR%
    128 if ""%1"" == ""debug"" goto use_jdk
    129 echo Using JRE_HOME:        %JRE_HOME%
    130 goto java_dir_displayed
    131 :use_jdk
    132 echo Using JAVA_HOME:       %JAVA_HOME%
    133 :java_dir_displayed
    134 
    135 set _EXECJAVA=%_RUNJAVA%
    136 set MAINCLASS=org.apache.catalina.startup.Bootstrap
    137 set ACTION=start
    138 set SECURITY_POLICY_FILE=
    139 set DEBUG_OPTS=
    140 set JPDA=
    141 
    142 if not ""%1"" == ""jpda"" goto noJpda
    143 set JPDA=jpda
    144 if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
    145 set JPDA_TRANSPORT=dt_shmem
    146 :gotJpdaTransport
    147 if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
    148 set JPDA_ADDRESS=jdbconn
    149 :gotJpdaAddress
    150 if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend
    151 set JPDA_SUSPEND=n
    152 :gotJpdaSuspend
    153 if not "%JPDA_OPTS%" == "" goto gotJpdaOpts
    154 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"" goto doDebug
    160 if ""%1"" == ""run"" goto doRun
    161 if ""%1"" == ""start"" goto doStart
    162 if ""%1"" == ""stop"" goto doStop
    163 if ""%1"" == ""version"" goto doVersion
    164 
    165 echo Usage:  catalina ( commands ... )
    166 echo commands:
    167 echo   debug             Start Catalina in a debugger
    168 echo   debug -security   Debug Catalina with a security manager
    169 echo   jpda start        Start Catalina under JPDA debugger
    170 echo   run               Start Catalina in the current window
    171 echo   run -security     Start in the current window with security manager
    172 echo   start             Start Catalina in a separate window
    173 echo   start -security   Start in a separate window with security manager
    174 echo   stop              Stop Catalina
    175 echo   version           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"" goto execCmd
    183 shift
    184 echo Using Security Manager
    185 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    186 goto execCmd
    187 
    188 :doRun
    189 shift
    190 if not ""%1"" == ""-security"" goto execCmd
    191 shift
    192 echo Using Security Manager
    193 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    194 goto execCmd
    195 
    196 :doStart
    197 shift
    198 if not "%OS%" == "Windows_NT" goto noTitle
    199 set _EXECJAVA=start "Tomcat" %_RUNJAVA%
    200 goto gotTitle
    201 :noTitle
    202 set _EXECJAVA=start %_RUNJAVA%
    203 :gotTitle
    204 if not ""%1"" == ""-security"" goto execCmd
    205 shift
    206 echo Using Security Manager
    207 set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    208 goto execCmd
    209 
    210 :doStop
    211 shift
    212 set ACTION=stop
    213 set CATALINA_OPTS=
    214 goto execCmd
    215 
    216 :doVersion
    217 %_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo
    218 goto end
    219 
    220 
    221 :execCmd
    222 rem Get remaining unshifted command line arguments and save them in the
    223 set CMD_LINE_ARGS=
    224 :setArgs
    225 if ""%1""=="""" goto doneSetArgs
    226 set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
    227 shift
    228 goto setArgs
    229 :doneSetArgs
    230 
    231 rem Execute Java with the applicable properties
    232 if not "%JPDA%" == "" goto doJpda
    233 if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
    234 %_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%" == "" goto doSecurityJpda
    241 %_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文件,代码如下:

    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         String dataName = request.getParameter("dataName");     
    12         if (dataName != null && dataName.length() > 0) {        
    13             String dataValue = 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             String name = (String)e.nextElement();       
    20             String value = session.getAttribute(name).toString();        
    21             out.println( name + " = " + value+"<br>");            
    22             System.out.println( name + " = " + value);      
    23         }   
    24     %>    
    25     <form action="test.jsp" method="POST">      
    26         名称:<input type=text size=20 name="dataName"><br/>      
    27         值:<input type=text size=20 name="dataValue"><br/>      
    28         <input type=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即可。

  • 相关阅读:
    [LintCode] Set Matrix Zeros
    [LintCode] Identify Celebrity
    [LintCode] Edit Distance
    [LintCode] Edit Distance II
    [LintCode] Strings Serialization
    二十七. Keepalived热备 Keepalived+LVS 、 HAProxy服务器
    二十六. 集群及LVS简介 LVS-NAT集群 LVS-DR集群
    二十五 存储技术与应用 iSCSI技术应用 、 udev配置 NFS网络文件系统 、 Multipath多路径 、 NFS网络文件系统 、 udev配置
    二十三.Subversion基本操作、使用Subversion协同工作、制作nginx的RPM包
    二十二. 安装部署Tomcat服务器、使用Tomcat部署虚拟主机、使用Varnish加速Web
  • 原文地址:https://www.cnblogs.com/jice/p/2410417.html
Copyright © 2020-2023  润新知