Load Balancing between APACHE-2.2.29 and tomcat-6.0.41 in CentOS-6.4-minimal

Source: Internet
Author: User
/*** In the CentOS-6.4-minimal version of Apache-2.2.29 and tomcat-6.0.41 Load Balancing * balance * about the Load balancer (Load balancer) and cluster (cluster) difference, and different configuration methods, later update * zookeeper * configuration load balancing * this article is based on Apache-2.2.29 and tomcat-6.0.41 integration, the integration process see http://blog.csdn.net/jadyer/article/details/39613523 * 1) modify the port (because I copied multiple Tomcat servers on one machine, you need to modify the port. skip this step if it is a different machine) * [[email protected] app] # vi tomcat/CONF/server. XML (modify 8005 to-1 for the reason see http://blog.csdn.net/jadyer/article/details/39613771) * [[email protected] app] # cp-r Tomcat extends AT1 * [[email protected] app] # cp-r Tomcat tomcat2 * [[email protected] app] # cp-R tomcat 3 * [[email protected] app] # vi extends AT1/CONF/server. XML (modify the SSL port to AJP ports 8543 and 8109, that is, + 100 respectively) * [[email protected] app] # vi tomcat2/CONF/server. XML (modify the SSL port to AJP ports 8643 and 8209, that is, + 100 respectively) * [[email protected] app] # vi tomcat3/CONF/server. XML (modify the SSL port to AJP ports 8743 and 8309, that is, + 100 respectively) * 2) Modify/APP/Apache/CONF/workers. properties. The modified content is as follows * worker. list = status, tomcatlb * worker. status. type = status * worker. tomcat1.port = 8109 * worker. tomcat1.host = 127.0.0.1 * worker. tomcat1.type = ajp13 * worker. tomcat1.lbfactor = 1 * worker. tomcat1.connection _ pool_timeout = 750 * worker. tomcat1.socket _ timeout = 300000 * worker. tomcat1.connect _ timeout = 10000 * worker. tomcat1.reply _ timeout = 330000 * worker. tomcat2.port = 8209 * worker. tomcat2.host = 127.0.0.1 * worker. tomcat2.type = ajp13 * worker. tomcat2.lbfactor = 1 * worker. tomcat2.connection _ pool_timeout = 750 * worker. tomcat2.socket _ timeout = 300000 * worker. tomcat2.connect _ timeout = 10000 * worker. tomcat2.reply _ timeout = 330000 * worker. tomcat3.port = 8309 * worker. tomcat3.host = 127.0.0.1 * worker. tomcat3.type = ajp13 * worker. tomcat3.lbfactor = 1 # load weight. The higher the value, the higher the probability of requests being distributed * worker. tomcat3.connection _ pool_timeout = 750 # idle connections maintained in the connection pool are released after several seconds. The default value is 0, that is, do not release * worker. tomcat3.socket _ timeout = 300000 # number of seconds for connecting JK to the Web server to time out. An error is generated when the timeout value is exceeded. The default value is 0, which means JK will keep waiting * worker. tomcat3.connect _ timeout = 10000 # Number of milliseconds after the request is sent until the response is received. The default value is 0, that is, wait for * worker. tomcatlb. type = LB # optional values: ajp13, ajp14, JNI, LB or status * worker. retries = 6 # repeated number of failed connections. The default value is 2 * worker. tomcatlb. balanced_workers = worker at1, tomcat2, tomcat3 # Web Server * worker involved in Server Load balancer. tomcatlb. sticky_session = 1*3) Modify/APP/Apache/CONF/extra/httpd-vhosts.conf * to change the default tomcat to tomcatlb, that is, specify all requests to be processed by tomcatlb * ---------------------------------------------------------------------------------------------------------------------- * test Server Load balancer * 1) After Apache and three Tomcat servers are started, you can view the three Tomcat servers and other parameters involved in Server Load balancer through jkstatus, we can also modify the Server Load balancer parameters through jkstatus * about jkstatus configuration and use, see http://blog.csdn.net/jadyer/article/details/39613553 * 2) next test the Server Load balancer access, the test code has been pasted below * access page. We will find that every time we refresh the page, we can see that the request is randomly allocated to three Tomcat servers through the background log, it indicates that the Server Load balancer is successful * and because no cluster is configured here, the sessionid printed on the page changes every time you refresh the page * worker * about workers. for more parameter descriptions of properties, refer to the following two URLs * http://tomcat.apache.org/connectors-doc/reference/workers.html * http://blog.csdn.net/chumeng411/article/details/7541767 * ---------------------------------------------------------------------------------------------------------------------- * @ create Sep 27,201 4 6:29:49 pm * @ author Xuan Yu 


<% @ Page Language = "Java" pageencoding = "UTF-8" %> <% system. out. println ("Local Address:" + request. getlocaladdr () + ":" + request. getlocalport (); out. println ("Local Address:" + request. getlocaladdr () + ":" + request. getlocalport () + "<br>"); %> <% Out. println ("<br> session ID:" + session. GETID () + "<br>"); Session. setattribute ("myname", "session"); string dataname = request. getparameter ("dataname"); If (null! = Dataname & dataname. length ()> 0) {string datavalue = request. getparameter ("datavalue"); Session. setattribute (dataname, datavalue);} Out. print ("<B> session List </B> <br>"); Java. util. enumeration E = session. getattributenames (); While (E. hasmoreelements () {string name = (string) E. nextelement (); string value = session. getattribute (name ). tostring (); out. println (name + "=" + value + "<br>") ;}%> <form action = "demo. JSP "method =" Post "> attribute name: <input type = text size = 20 name =" dataname "> <br> attribute value: <input type = text size = 20 name = "datavalue"> <br> <input type = submit> </form>


Load Balancing between APACHE-2.2.29 and tomcat-6.0.41 in CentOS-6.4-minimal

Related Article

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.