Apache Load Balancing +tomcat cluster Connector port= "8009" protocol= "ajp/1.3"

Source: Internet
Author: User
Tags server port
APACHE 2.2.8+tomcat6.0.14 Configuration load Balancing < XmlNamespace prefix = "o" ns = "Urn:schemas-microsoft-com:office:office"/> Target:Use Apache and Tomcat to configure a Web site that can be applied, to meet the following requirements: 1, Apache as a httpserver, followed by a number of Tomcat application instances, and load balancing. 2, set the session timeout for the system, including Apache and Tomcat 3, for the System screen file list, including Apache and Tomcat Note: This routine in a machine as an example, that is, the same machine with an Apache and 4 tomcat. First, preparatory work: Installation of the program (the prerequisite to ensure that the JDK1.5 has been installed above the version)Apahce 2.2.8 Download: apache_2.2.8-win32-x86-no_ssl.msi tomcat< xmlnamespace prefix = "st1 ns =" urn:schemas-microsoft-com : Office:smarttags "/>6.0.14 download: Apache-tomcat-6.0.14.zip directly decompression. second, the installation processAPAHCE installation directory: D:\Apache. Four Tomcat directories: Unzip yourself to (D:\Tomcat Cluster Server \). The installation process for tomcat6.0,tomcat6.01,tomcat6.02,tomcat6.03, respectively, is not explained in detail. Third, the configuration 1, Apache configuration 1.1, httpd.conf configurationModify Apache configuration file D:\Apache \conf\httpd.conf The following module comments out, there is no use mod_jk.so for Apache and Tomcat links, from 2.X after the Apache itself has been integrated mod_ The jk.so function. Simply take the following lines off the annotation, which is equivalent to the previous use of mod_jk.so more cumbersome configuration. Here the main use of the proxy method, it is so simple.
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 then find <ifmodule dir_module></ifmodule> Plus index.jsp modified into <ifmodule dir_module> DirectoryIndex index.html index.jsp</IfModule> 1.1.1, join at the bottomProxyrequests off <proxy balancer://cluster> balancermember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 Balancermember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2 balancermember ajp://127.0.0.1:9001 loadfactor=1 route= JVM3 balancermember ajp://127.0.0.1:9003 loadfactor=1 route=jvm4 </proxy> top four BalancermemberThe members are our configured tomcat cluster. It will be explained later. 1.2, httpd-vhosts.conf settingsNext, the settings for the virtual host. Apache's virtual host settings are as follows: First, modify the conf/httpd.conf find (#Include conf/extra/httpd-vhosts.conf) to remove the annotations. # Virtual hosts include conf/extra/httpd-vhosts.conf at the bottom of the file (extra/httpd-vhosts.conf) add <virtualhost *:80> S Erveradmin weijie@126.com ServerName localhost serveralias localhost Ster/stickysession=jsessionid nofailover=on proxypassreverse/balancer://cluster/</VirtualHost> the domain name and path Set up and then set up Tomcat virtual host on your own condition 2 Configuring Tomcat 2.1. Configure the shutdown of the serverWe need to run 4 different tomcat on a single machine, and we need to modify the different Tomcat's closing ports to avoid the occurrence of port occupancy. Where tomcat6.0 with the default value, not modified. Three other modifications. Server is found in Server.xml under Tomcat6.01\conf, tomcat6.02\conf, and tomcat6.03\conf: <server port= "8005" SHUTDOWN "> Changed to <server port=" xxxx "shutdown=" SHUTDOWN "> XXXX here represents a different port: My other three Tomcat uses 9005,8006, 9007 2.2. Configure EnginePut the original configuration Comment out, put the following sentence Remove Comments。 and marked jvmroute= "JVM2". <engine name= "Standalone" defaulthost= "localhost" jvmroute= "jvm2" > Below is the original configuration. The <!--<engine name= "Catalina" defaulthost= "localhost" >--> other (tomcat6.02 and tomcat6.03) are also configured. Note: Jvmroute configuration is not the same. <engine name= "Standalone" defaulthost= "localhost" jvmroute= "jvm3" > <engine name= "Standalone" defaulthost= " localhost "jvmroute=" JVM4 "> 2.3. Configure Connector The original default configuration. <!--Define a AJP 1.3 Connector on port 8009--> <connector port= "8009" protocol= "ajp/1.3" redirectport= "8443" /> Here is the key to Apache and Tomcat links, the front desk Apache is through the AJP protocol to communicate with Tomcat to complete the load balancing function. You can also use the HTTP protocol. Notice how they connect to the communication, and the red section above (port= "8009") is the interface of the connection. Change the other three tomcat <connector port= "XXX"/>port to <proxy balancer://cluster>      # respectively. Corresponding with tomcat6.0, route and <engine jvmroute= "JVM1" > corresponding. Balancermember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 #与tomcat6.01, Route corresponds to <engine jvmroute= "jvm2" >. Balancermember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2 #与tomcat6.02, Route corresponds to <engine jvmroute= "jvm3" >. Balancermember ajp://127.0.0.1:9001 loadfactor=1 route=jvm3 #与tomcat6.03, Route corresponds to <engine jvmroute= "JVM4" >. Balancermember ajp://127.0.0.1:9003 loadfactor=1 route=jvm4 port corresponds to tomcat6.01 port AJP. tomcat6.02 AJP Port port:9001. tomcat6.03 AJP Port port:9003. Be sure to be consistent with the above. Also, change the value of Redirectport to be unique, making sure that four Tomcat is different. 2.5. Configure cluster (to be modified in each tomcat) The original configuration. <cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> modified to the following code: <receiver port= "XX"/> Port also to ensure uniqueness. <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=" "Droptime=" 3000 "/> <receiver classname=" org.apache.catalina.tribes.transport.nio.NioReceiver "address=" Auto "port=" 5001 "Selectortimeout=" 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" Org.apache.catalina.ha.session.ClusterSessionListener "/> </Cluster> This setting is primarily used for Tomcat clusters. Four, start the service, test the example of Tomcat with1, Test Apache and Tomcat collaboration. First in each tomcat under the \webapps\root under the index.jsp under the following Test Code section: (x represents different tomcat output different information), the index.html deleted, so as not to affect the test results. At the end of the Add. Between </table></body>. <% System.out.println ("tomcat6.0x deal with request"); %> and then through the http://127.0 0.1来 visit, there will be familiar with the cat. And then through the separate access to http://127.0.0.1:8080, http://127.0.0.1:9080,http://127.0.0.1:8081,http:// 127.0.0.1:9002 the content they visit is the same as the http://127.0.0.1 above. This illustrates the success of Apache and Tomcat consolidation. 2, the test equalizer through http://127.0.0.1 multiple visits, to see the real effect, you must use a number of stress testing tools, Microsoft WEB Application Stress tool for simple stress testing, Otherwise, you will not be able to keep refreshing, you can only be in a tomcat console has output results. Using only the stress test tool to simulate a large number of users at the same time access, you will find that four Tomcat console has the control information, indicating that the equalizer is working properly.

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.