Apache Server and Tomcat cluster Configuration II: Vertical Load

Source: Internet
Author: User

A vertical load is the load between different servers in the same machine. The biggest difference from a horizontal load (the load between servers with different IPs) is to modify the tomcat port number to avoid causing conflicts.

Also pay attention to Apache in the configuration of Workers.properties (Worker.controller.sticky_session=false), this must cancel the sticky session, or will always be sent to the same server.

The main modification points are

1. Modify Tomcat's AJP port number to avoid causing conflicts

2.workers.properties configuration, Worker.controller.sticky_session=false, cancel sticky session

3. Open the Tomcat cluster tag to enable it to support the cluster, after opening a tomcat, open another Tomcat, if the following output appears, the cluster join succeeds:

Info: Replication member Added:org.apache.catalina.tribes.membership.memberimpl[tcp://{169, 254, 81, 38}  : 4001,{169, 254, Bayi, 38},4001, alive=1029, Secureport=-1, UDP Port=-1, id={44-83 62 97-76 55 65 79-85 47 35-124 127 75 payload={}, command={}, domain={},]

4. Open Apache, test cluster, different tomcat node under SessionID is the same as indicating cluster success:

The following is the Worker.properties configuration file:

#下面是Tomcat实例列表, an Apache with one or more tomcatworker.list=Controller,tomcat1,tomcat2#tomcatbbs instance Configuration Worker.tomcat1.host=127.0.0.1Worker.tomcat1.port=8009#ajp13 port number, server.xml configuration under Tomcat, default 8009 worker.tomcat1.type=Ajp13worker.tomcat1.lbfactor= -#server的加权比重, the higher the value, the more requests to be #tomcatwap instance configuration Worker.tomcat2.host=127.0.0.1Worker.tomcat2.port=9009Worker.tomcat2.type=Ajp13#server weighted weight, the higher the value, the more requests to be divided Worker.tomcat2.lbfactor= -   #========controller, Load Balancer controller ========Worker.controller.type=lb# specify tomcatworker.controller.balanced_workers to share requests=TOMCAT1,TOMCAT2 #设置用于负载均衡的server的session可否共享1: Sharing worker.controller.sticky_session=false

The main configuration of Tomcat's Server.xml:

<ConnectorPort= "8009"Protocol= "ajp/1.3"Redirectport= "8443" />    <!--An Engine represents, the entry point (within Catalina), that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes T         Hem on to the appropriate host (virtual host). Documentation At/docs/config/engine.html -    <!--should set Jvmroute to support load-balancing via AJP ie: <engine name= "Catalina" defaulthost= "localhost" Jvmroute= "JVM1" > -    <Enginename= "Catalina"Defaulthost= "localhost"Jvmroute= "TOMCAT1">      <!--for clustering, take a look at documentation at:/docs/cluster-howto.html ocs/config/cluster.html (reference documentation) -      <!--<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> -      <!--Use the Lockoutrealm to prevent attempts to guess user passwords via a brute-force attack -      <RealmClassName= "Org.apache.catalina.realm.LockOutRealm">        <!--This Realm uses the userdatabase configured in the global JNDI resources under the key "Userdatabase". Any edits that is performed against this userdatabase is immediately available for use by the Re  Alm.  -        <RealmClassName= "Org.apache.catalina.realm.UserDatabaseRealm"resourcename= "Userdatabase"/>      </Realm>      <Hostname= "localhost"AppBase= "WebApps"Unpackwars= "true"Autodeploy= "true">        <!--Singlesignon valve, share authentication between Web applications documentation at:/docs/config/valve.ht ML -        <!--<valve classname= "Org.apache.catalina.authenticator.SingleSignOn"/> -        <!--Access Log processes all example. Documentation at:/docs/config/valve.html note:the pattern used are equivalent to using pattern= "common" -        <ValveClassName= "Org.apache.catalina.valves.AccessLogValve"Directory= "Logs"prefix= "Localhost_access_log"suffix= ". txt"pattern= "%h%l%u%t &quot;%r&quot;%s%b" />      </Host>    </Engine>

Another configuration for Tomcat:

<!--Define an AJP 1.3 Connector on port 8009 -    <ConnectorPort= "9009"Protocol= "ajp/1.3"Redirectport= "8443"/>    <!--An Engine represents, the entry point (within Catalina), that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes T         Hem on to the appropriate host (virtual host). Documentation At/docs/config/engine.html -    <!--should set Jvmroute to support load-balancing via AJP ie: <engine name= "Catalina" defaulthost= "localhost" Jvmroute= "JVM1" > -    <EngineDefaulthost= "localhost"name= "Catalina"Jvmroute= "Tomcat2">      <!--for clustering, take a look at documentation at:/docs/cluster-howto.html ocs/config/cluster.html (reference documentation) -      <ClusterClassName= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/>      <!--Use the Lockoutrealm to prevent attempts to guess user passwords via a brute-force attack -      <RealmClassName= "Org.apache.catalina.realm.LockOutRealm">        <!--This Realm uses the userdatabase configured in the global JNDI resources under the key "Userdatabase". Any edits that is performed against this userdatabase is immediately available for use by the Re  Alm.  -        <RealmClassName= "Org.apache.catalina.realm.UserDatabaseRealm"resourcename= "Userdatabase"/>      </Realm>      <HostAppBase= "WebApps"Autodeploy= "true"name= "localhost"Unpackwars= "true">        <!--Singlesignon valve, share authentication between Web applications documentation at:/docs/config/valve.ht ML -        <!--<valve classname= "Org.apache.catalina.authenticator.SingleSignOn"/> -        <!--Access Log processes all example. Documentation at:/docs/config/valve.html note:the pattern used are equivalent to using pattern= "common" -        <ValveClassName= "Org.apache.catalina.valves.AccessLogValve"Directory= "Logs"pattern= "%h%l%u%t &quot;%r&quot;%s%b"prefix= "Localhost_access_log."suffix= ". txt"/>      <ContextDocBase= "Testcluster"Path= "/testcluster"reloadable= "true"Source= "Org.eclipse.jst.jee.server:TestCluster"/></Host>    </Engine>

Apache Server and Tomcat cluster Configuration II: Vertical Load

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.