[Summary] configure apache2.2 Server Load balancer + atat6 Cluster

Source: Internet
Author: User
Configure apache2.2load balancing tomctomcat6cluster .txt
References:
Http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/mod/mod_proxy.html
Http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/mod/mod_proxy_balancer.html

The so-called load balancing refers to the fact that a single server cannot respond to a large number of requests within a short period of time on the server side,
In this case, the server requires a mechanism to distribute requests according to the different load capacities of multiple servers.
A cluster is used to share user information and resources among multiple servers.

Note: One apache2.2 server and two Tomcat servers
One Server Load balancer apache2.2 server is responsible for request balancing. Cluster Server A and Cluster Server B form a cluster. When a cluster server crashes, the other server continues to be responsible for running the application.
Introduction: Apache's support for Tomcat history: After apache version 2.1, it has a built-in proxy_ajp, while JK2 is no longer developed. JK supports apache version 2.0.58. Proxy_ajp is relatively simple to configure, but it is not as configurable as JK2, mainly because proxy_ajp currently only supports configuration to the directory, the pattern matching of file names is not supported yet (that is, it cannot be defined to work only for JSP files ).

Install JDK or later, install apache2.2, install Tomcat 6, configure Apache load balancing, and configure Tomcat Cluster

1. Install JDK (all Tomcat hosts, that is, Web servers)
1. Download the JDK bin package
2. Set the environment variable # vi/etc/profile to add it at the end
Java_home =/usr/Java
Export java_home
Classpath =/usr/Java/lib:/usr/Java/JRE/lib
Export classpath
Path = $ pathjava_home/binjava_home/JRE/bin
Export path
JRE =/usr/Java/JRE
Export JRE
Save and exit

2. Configure the server Load balancer server apache2.2
1. Download apache2.2.4 and install related components
Bytes
Installation Method:
Decompress: gzip-D apache-2.2.4-sol10-x86-local.gz
Install: pkgadd-D apache-2.2.4-sol10-x86-local

2. view the modules compiled into Apache:
# Cd/usr/local/apache2/bin
# Httpd-l
Compiled in modules:
Core. c
Prefork. c
Http_core.c
Mod_so.c

3. Modify the/usr/local/apache2/CONF/httpd. conf file.

Remove the comments of the following module (actually removed)
Loadmodule proxy_module modules/mod_proxy.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
Loadmodule proxy_ajp_module modules/mod_proxy_ajp.so
Loadmodule proxy_balancer_module modules/mod_proxy_balancer.so

And add
<Location/Server-status>
Sethandler server-status
Order deny, allow
Deny from all
Allow from all
</Location>
<Location/balancer-Manager>
Sethandler balancer-Manager
Order deny, allow
Deny from all
Allow from all
</Location>
Proxyrequests off
Proxypass/balancer: // tomcatcluster/stickysession = JSESSIONID nofailover = on
Proxypass/temp HTTP :/// 192.168.1.8: 8080/temp/
# Proxypassreverse/balancer: // tomcatcluster/
Proxypassreverse/CCAs balancer: // tomcatcluster/CCAs/
Proxypassreverse/clpay balancer: // tomcatcluster/clpay/

<Proxy balancer: // tomcatcluster>
Balancermember AJP: // 192.168.1.8: 8009 loadfactor = 1
Balancermember AJP: // 192.168.1.29: 8009 Smax = 1 loadfactor = 1
# Less powerful server, don't send as your requests there
Balancermember AJP: // 192.168.1.29: 80 Smax = 1 loadfactor = 2
</Proxy>

Proxypass is the proxy forwarding URL, which forwards all access/requests to the cluster balancer: // tomcatcluster
Balancermember is a member of the cluster, that is, cluster server a or server B. The Server Load balancer forwards requests to balancermember according to the Server Load balancer rules.

After configuration, start the apahce server and access localhost to view the results returned by applications on the cluster server. Congratulations! The Server Load balancer and cluster have been configured successfully.
Access localhost/balancer-manager to Display Server Load balancer information.

4. Go to the/usr/local/apache2/bin directory and run
#./Apachectl configtest command to check whether the configuration is correct
Syntax OK is displayed, indicating that the configuration is correct.
5. Start/Close/restart Apache
Start Apache
#./Apachectl start

Disable Apache
#./Apachectl stop

3. install and configure the tomcat6 Cluster
1. Download apache-tomcat-6.0.13.tar.gz (http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.13/bin/apache-tomcat-6.0.13.tar.gz)
2.install apache-tomcat-6.0.13.tar.gz
Install it in the/usr/Apache/tomcat directory
# Gzip-D apache-tomcat-6.0.13.tar.gz
3. Fixed an error in displaying the verification code under Solaris.
Add-djava. AWT. Headless = true/to line 266/278 of/usr/Apache/tomcat/bin/Catalina. Sh/
4. Start the Tomcat server to test whether it is normal.
# Cd/usr/Apache/tomcat/bin/
#./Startup. Sh

5. Modify Tomcat's CONF/server. xml <engine> (configured when ARP is used)
Remove the comment <engine name = "standalone" defaulthost = "localhost" jvmroute = "tomcat1">
Jvmroute is the Tomcat route label, which distinguishes two Tomcat hosts, then the second is changed
<Engine name = "standalone" defaulthost = "localhost" jvmroute = "tomcat2">
Add <engine name = "Catalina" defaulthost = "localhost">
6. Modify Tomcat's CONF/server. xml <connector> (configured when ARP is used)
Remove comments <connector Port = "8009" enablelookups = "false" redirectport = "8443" DEBUG = "0" protocol = "AJP/1.3"/>
7. Modify Tomcat's CONF/server. xml <cluster>
<! --
<Cluster classname = "org. Apache. Catalina. Ha. tcp. simpletcpcluster"/>
-->
<Cluster classname = "org. Apache. Catalina. Ha. tcp. simpletcpcluster"
Channelsendoptions = "6">

<Manager classname = "org. Apache. Catalina. Ha. session. backupmanager"
Expiresessionsonshutdown = "false"
Notifylistenersonreplication = "true"
Mapsendoptions = "6"/>
<! --
<Manager classname = "org. Apache. Catalina. Ha. session. deltamanager"
Expiresessionsonshutdown = "false"
Notifylistenersonreplication = "true"/>
-->
<Channel classname = "org. Apache. Catalina. tribes. Group. groupchannel">
<Membership classname = "org. Apache. Catalina. tribes. Membership. mcastservice"
Address = "228.0.0.4"
Port = "45564"
Frequency = "500"
Droptime = "3000" type = "codeph" text = "codeph"/>
<Cycler classname = "org. Apache. Catalina. tribes. Transport. NiO. nioreceiver"
Address = "Auto"
Port = "5000"
Selectortimeout = "100"
Maxthreads = "6"/>

<Sender classname = "org. Apache. Catalina. tribes. Transport. replicationtransmitter">
<Transport classname = "org. Apache. Catalina. tribes. Transport. NiO. pooledparallelsender"/>
</Sender>
<Interceptor classname = "org. Apache. Catalina. tribes. Group. interceptors. tcpfailuredetector"/>
<Interceptor classname = "org. Apache. Catalina. tribes. Group. interceptors. messagedispatch15interceptor"/>
<Interceptor classname = "org. Apache. Catalina. tribes. Group. interceptors. throughputinterceptor"/>
</Channel>

<Valve classname = "org. Apache. Catalina. Ha. tcp. replicationvalve"
Filter = ". */. GIF ;. */. JS ;. */. JPG ;. */. PNG ;. */. htm ;. */. HTML ;. */. CSS ;. */. txt; "/>

<Deployer classname = "org. Apache. Catalina. Ha. Deploy. farmwardeployer"
Tempdir = "/tmp/war-temp /"
Deploydir = "/tmp/war-deploy /"
Watchdir = "/tmp/war-Listen /"
Watchenabled = "false"/>

<Clusterlistener classname = "org. Apache. Catalina. Ha. session. clustersessionlistener"/>
</Cluster>

8. In each webapps, modify the configuration file web. xml file to add elements <distributable/>
Add the following content to the <web-app> element of the web. xml file:
<! -- This application will copy the session with the cluster server -->
<Distributable/>
The specific modification is as follows:
Before modification:
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<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">
</Web-app>
After modification:
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<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">
<! -- This application will copy the session with the cluster server -->
<Distributable/>
</Web-app>

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.