Configure Tomcat cluster and sticky mode in Apache

Source: Internet
Author: User

Let's talk about the environment:

Apache 2. 2 .*

Tomcat6

Windows XP SP3

Jdk I think everyone should be over 1.6.

I only made two Tomcat clusters here.

Install apahce

Find the httpd. conf file in the installation directory.

Add the following content to others:

Proxypass/balancer: // tomcatcluster/lbmethod = byrequests stickysession = JSESSIONID nofailover = off timeout = 5 maxattempts = 3
Proxypassreverse/balancer: // tomcatcluster/

<Proxy balancer: // tomcatcluster>
Balancermember AJP: // localhost: 8009 route =
Balancermember AJP: // localhost: 9009 route = B
</Proxy>
<Virtualhost *: 80>
Serveradmin fengqingtao@gmail.com
Servername localhost
Proxypass/balancer: // tomcatcluster/
Proxypassreverse/balancer: // tomcatscluster/
Errorlog "log/dummy-host2.localhost-error.log"
Customlog "logs/dummy-host2.localhost-access.log" common
</Virtualhost>

Uncomment the following strings.

#### --------- Cluster ----------------###
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
#### --------- Cluster ----------------###

Finally, open CONF/server. XML in Tomcat.

Find this sentence:

<Engine name = "Catalina" defaulthost = "localhost">

Changed to: <engine name = "Catalina" defaulthost = "localhost" jvmroute = "A">

Modify server. xml of another tomcat

<Engine name = "Catalina" defaulthost = "localhost" jvmroute = "B">

Restart Apache and start Tomcat.

of course, if you run Tomcat on the same computer, you must change the port. Check the Tomcat port on the Internet.

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.