Apache + tomcat load balancing, apachetomcat
Note: This article is not intended for developers without development basics, so there are no software downloads, jdk installation, and other steps. Something that's older ......
1. System Environment
Win7-64, jdk
2. Software List:
Apache_2.2.24-x64-no-ssl.msi, tomcat5
3. configuration steps:
1) configure the method used to achieve load balancing.
2) Change the Port Related to the tomcat configuration file (I tested it on the local machine and there are multiple tomcat servers on the local machine)
3) connect to apache and tomcat
4. Start Configuration
1) modify the conf/httpd. conf file in the apache installation directory
What is the function of removing the following comments (that is, removing the # sign? After cancellation, you can use proxy to achieve load balancing! (111 rows-116 rows)
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
The code for loading a configuration file also needs to be released (471 rows)
1 Include conf/extra/httpd-vhosts.conf
2) Configure tomcat
Modify the ports in your Tomcat \ conf \ server. xml file (too simple to skip)
3) Configure VirtualHost
In the apache installation directory conf/extra/httpd-vhosts.conf file to add, there is no need to add, the port can also be changed here, including ip is *
<VirtualHost *: 80> ServerAdmin administrator email ServerName localhost ServerAlias localhost ProxyPass/balancer: // sy/stickysession = jsessionid nofailover = On ProxyPassReverse/balancer: // sy/ErrorLog "logs/sy-error.log" CustomLog "logs/sy-access.log" common </VirtualHost>
4) Interconnection
The point is, the connection is correct. The following code is written in conf/httpd. conf under the apache installation directory (this file can also modify the port settings ).
The emphasis here is on the port number. The default tomcat port is used. For example, if port 8080 is port 8009, you can directly access tomcat using port 8080,
However, 8009 is used here.
ProxyRequests Off<proxy balancer://sy> BalancerMember ajp://127.0.0.1:18009 loadfactor=1 route=jvm1 BalancerMember ajp://127.0.0.1:28009 loadfactor=1 route=jvm2</proxy>
5. Test
1) create a project and deploy it to tomcat
2) start apache and tomcat and access
3) if the access page displays Service Temporarily Unavailable
Please read Step 4 carefully)
6. sessino sharing, Open tomcat. Comments of <Cluster nodes in server. xml under conf will be shared by all projects.
Just want to share one? Add <distributable/> to project web. xml
7. If you do not want to configure the content...
Download link: http://files.cnblogs.com/files/wchb/apache%E8%B4%9F%E8%BD%BD%E9%85%8D%E7%BD% AE .7z