Apache Load Balancer APACHE2.4.18+TOMCAT7 (Windows edition)

Source: Internet
Author: User
Tags server port

One: Install download on Apache official website to download Apache version of the latest version of Apache on the line here is the latest apache2.4.18 decompression to any disk after the installation in CMD, such as to D:\apache\Apache24\bin under the command httpd-k Install


After that, the download of JK JK in Tomcat is the application of Tomcat to the HTTP service, which can then be extracted in D:\apache\Apache24\modules


Then you need to install Tomcat to copy N copies (n= how much you need to load) Note that the Tomcat version needs to be consistent don't one is TOMCAT6 one is TOMCAT7


Two: Configuration

1. Configure the Apache configuration file D:\apache\Apache24\conf (this is my path) first httpd.conf


First load the downloaded JK LoadModule jk_module modules/mod_jk.so in the LoadModule loading bottom


After that, LoadModule Rewrite_module modules/mod_rewrite.so Front # is removed.


The next step is to

<ifmodule jk_module>

Jkworkersfile conf/workers.properties

Jkmount/* Controller

Jklogfile Logs/mod_jk.log #这条和下面这条可以取消删掉

Jkloglevel warn

</IfModule>

Add to the bottom of the configuration


2. Create a new workers.properties file in D:\apache\Apache24\conf

  1. Worker.list = Controller

  2. #========tomcat1========

  3. worker.tomcat1.port=8009 #指定tomcat2服务器AJP的端口, default is 8009

  4. worker.tomcat1.host=localhost #指定tomcat2服务器IP或域名

  5. WORKER.TOMCAT1.TYPE=AJP13 #指定tomcat2与apache AJP Communication protocol

  6. Worker.tomcat1.lbfactor=1 #指定负载平衡因数 is only useful if load balancing is enabled.

  7. #========tomcat2========

  8. worker.tomcat2.port=8010

  9. worker.tomcat2.host=172.168.1.31 #也可以用远程

  10. Worker.tomcat2.type=ajp13

  11. Worker.tomcat2.lbfactor=1

  12. #========controller Load Balancing Controller ========

  13. WORKER.CONTROLLER.TYPE=LB #指定controller类型

  14. WORKER.CONTROLLER.BALANCED_WORKERS=TOMCAT1,TOMCAT2 #指定负载平衡的tomcat

  15. Worker.controller.sticky_session=true #指定是否粘性session

  16. Worker.controller.sticky_session_force=false

  17. worker.connection_pool_size=3000

  18. Worker.connection_pool_minsize=50

  19. worker.connection_pool_timeout=50000

  20. # Session Configuration Description:

  21. #当sticky_session, Sticky_session_force are true when the session is not copied,

  22. #sticky_session_force =false refers to a server in a cluster where multiple requests are not responding, then forwarded to other servers for processing,

  23. #sticky_session =false does not use sticky session, while configuring not to copy session, note that the original session may not be found after forwarding the request.


3. Modify the Conf/server.xml of each tomcat

Modify <server port= "10934" shutdown= "shutdown" > Shutdown ports each change to a different one otherwise tomcat cannot be turned on at the same time


After you modify the Tomcat port

<connector port= "8443" protocol= "Org.apache.coyote.http11.Http11Protocol"

Maxthreads= "sslenabled=" true "scheme=" "https" secure= "true"

Clientauth= "false" sslprotocol= "TLS"/>

Make each tomcat port inconsistent and not occupied

<connector port= "10888" protocol= "ajp/1.3" redirectport= "8443"/> After the AJP port is modified to match the port in workers


The next step

<engine name= "Catalina" defaulthost= "localhost" jvmroute= "TOMCAT1" > Comment Open the name of the tomcat1 himself and put the note or delete the one below him.

<engine name= "Catalina" defaulthost= "localhost" >


and the following <cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> Annotation Open is to open a simple TCP cluster;


4. modify the Web. xml file in the Web-inf directory, add tags

<distributable/>
Just add it to </web-app> before you can, because this is assignable.

Then you're done.

This article from "Faint blog" blog, reproduced please contact the author!

Apache Load Balancer APACHE2.4.18+TOMCAT7 (Windows edition)

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.