Multiple instances of Tomcat machine

Source: Internet
Author: User

Environment

tomcat:/home/tomcat-6.0.45

Oms-client
Site Program:/home/oms-client/oms-book-client

Site Tomcat instance:/home/oms-client/tomcat6-sever1

Port: 38080

Bms-client

Site Program:/home/bms-client/bms-book-client

Site Tomcat instance:/home/bms-client/tomcat6-sever2 Port: 48080

1. Tomcat Installation

Installation is simple, configure the JDK and extract Tomcat.


The first thing we see is Tomcat's directory structure, each of which has the following uses: bin– contains all binaries and script files that run Tomcat lib– contains all shared library conf used by Tomcat-contains configuration information, such as the Tomcat-bound port logs– contains Some log files temp– This directory is a temporary file hosted by Tomcat webapps– This directory is important to store all the application war packages work– if the application contains JSP files, then each JSP file is compiled into a servlet and stored in this

When we run Tomcat, we use 5 environment variables. They are: catalina_home catalina_base catalina_tmpdir jre_home/java_home CLASSPATH

In the list above, Catalina_home and java_home are necessary environment variables. The other can be converted by catalina_home, which is optional.

catalina_home– This environment variable is the root directory of Tomcat installation/extraction. So through Catalina_home, you get the bin and Lib directories.

catalina_base– is a catalina_home value if it is not specified. The variable points to a directory containing each run instance needs to use its own conf, logs, temp, WebApps, work directories.

The general way to run Tomcat is to set the Catalina_home variable only, execute the startup.sh script, and startup.sh automatically convert other variables that are not set.
2. Configure multiple instance directories

Create Oms-client, bms-client in the Tomcat installation directory, create Tomcat instance 1 Tomcat6-server1 in oms-client and add conf, logs, temp, WebApp, The work directory is copied to both directories, and then the Tomcat installation directory can be left entirely. The configured directory structure is as follows:



Note: The screenshot has a bin directory, in fact the bin directory will only be put back to the start and delete. sh, the original file has been deleted 3. Configure site Server.xml

3.1 Configuration Tomcat6-server1

The ports that need to be modified are: Shutdown port,connector port,ajp Port and redirect port.

Shutdown port– This port is used to turn off Tomcat. When the shutdown.sh script is executed, it sends a signal to the port, and the Tomcat process listens to the port, and if it receives such a signal, the process clears out.

Connector Port-This is the port where the application is externally published.

AJP Port–web servers (such as Apache's httpd server) communicate with Tomcat through this port, or you can use it to set up a load-balancing server.

Redirect port– If this connector supports non-SSL requests and receives SSL requests, Catalina will automatically point the request to this port.




Modify Shutdown port

Modify Connectors Port and Redirectport


Modify Connectors Port and Redirectport

Modify host to join <context path= "" docbase= "/home/oms-client/oms-book-client" reloadable= "false"/> where DocBase is the project address


3.2 Configuration Tomcat6-server2

Ditto, several port numbers have to be changed as well
4. Multi-instance startup script

Create a startup script tomcat.sh under the/home/bms-client/tomcat6-sever1/bin,/home/bms-client/tomcat6-sever2/bin directory, The main difference between the two tomcat.sh is that catalina_base different
4.1 Script Content Tomcat.sh

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #!/bin/sh # Description: Start tomcat multiple instances. . /Etc/init. D/functions RETVAL = $? # Tomcat Instance Directory export Catalina_base = "/home/oms-client/tomcat6-server1" # Tomcat installation directory Export Catalina_home = "/HOME/TOMCA t-6.0.45 "# Optional export jvm_options

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.