Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of how to realize apache+tomcat load balancing configuration

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The following gives you a detailed explanation of how to achieve apache+tomcat load balancing configuration, hoping to give you some help in practical application. Load balancing involves a lot of things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

1. System environment

Win7-64, jdk

two。 Software list:

Apache_2.2.24-x64-no-ssl.msi 、 tomcat5

3. Instructions for configuration steps:

1) configure which method is used to achieve load balancing.

2) change the port related to the tomcat profile (I tested it on this machine, which has multiple tomcat)

3) docking apache and tomcat

4. Configuration start

1) modify the conf/httpd.conf file under the apache installation directory

Remove the following comments (that is, go to the #), what is the use? After cancellation, you can use proxy (proxy) to achieve load balancing! (lines 111-116)

1 LoadModule proxy_module modules/mod_proxy.so2 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so3 LoadModule proxy_balancer_module modules/mod_proxy_balancer.so4 LoadModule proxy_connect_module modules/mod_proxy_connect.so5 LoadModule proxy_ftp_module modules/mod_proxy_ftp.so6 LoadModule proxy_http_module modules/mod_proxy_http.so

And the code that loads a configuration file should also be released (line 471)

1 Include conf/extra/httpd-vhosts.conf

2) configure tomcat

Modify the various ports in your Tomcat\ conf\ server.xml file (too simplistic and skip)

3) configure VirtualHost

Add it to the conf/extra/httpd-vhosts.conf file of the apache installation directory, and you don't need to add it. The port can also be changed here, including ip, which is *

ServerAdmin administrator mailbox ServerName localhost ServerAlias localhost ProxyPass / balancer://sy/ stickysession=jsessionid nofailover=On ProxyPa***everse / balancer://sy/ ErrorLog "logs/sy-error.log" CustomLog "logs/sy-access.log" common

4) docking

The point is, docking, yes, is the following code, written in the conf/httpd.conf under the apache installation directory (this file can also modify the port settings).

What is emphasized here is the port number, which is explained by the default port of tomcat, such as port 8080, port 8009, and you use 8080 to access tomcat directly.

But in this case, it's 8009.

ProxyRequests Off BalancerMember ajp://127.0.0.1:18009 loadfactor=1 route=jvm1 BalancerMember ajp://127.0.0.1:28009 loadfactor=1 route=jvm2

5. test

1) create a new project and deploy to tomcat

2) start apache,tomcat and visit

3) if you encounter a visit page that displays Service Temporarily Unavailable

Then please read step 4 carefully.

6.sessino sharing, release the server.xml under tomcat,conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report