Tomcat+apache Load Balancing

Source: Internet
Author: User

1.jdk1.8 and Tomcat7.0 are not compatible and support Tomcat8.0.

Cluster architecture diagram:

2. Load balancing: The base of the load is the cluster, the cluster is a group of computers connected together, from the external view it is a system, each node can be different operating systems or different hardware components of the computer. A cluster that provides Web services looks like a large Web server to the outside world. Load is the load pressure according to an algorithm reasonable allocation to each computer in the cluster, to reduce the pressure on the primary server, reduce the hardware and software requirements of the primary server.

3. Deployment method: APACHE2.2+TOMCAT7.0+JDK1.7+JK

Main method: Http://www.finereporthelp.com/help/24/1/3/3.html

Main steps : (JDK+TOMCAT+APACHE+MOD_JK)

1. Install Jdk,tomcat on each server (the installation of Tomcat, enter localhost:8080 in the browser, will enter the Tomcat page);

2. Install Apache on the anti-proxy server (install successfully, enter localhost in the browser, will show the installation success);

3. Change the Apache installation path conf The following httpd.conf, on its last line, add: include "Apache installation path \conf\mod_jk.conf";

4. Under Conf, create a new mod_jk.conf file formatted as. conf and add the following code:

LoadModule jk_module modules/mod_jk.so    //requires modules import under Apache installation path Mod_jk.sojkworkersfile conf/ Workers.properties  //Load Balancer Jkmount/*.jsp controller    //*.jsp can be changed to * to support all file formats

5. Create a new Workers.properties file under Conf and add the following code:

#serverworker. List = controller#========tomcat1========    //How many servers are established tomcatworker.tomcat1.port=11009   // Each server is a tomcat, and the corresponding port is not the same worker.tomcat1.host=localhostworker.tomcat1.type=ajp13worker.tomcat1.lbfactor = 1#====== ==tomcat2========worker.tomcat2.port=12009worker.tomcat2.host=localhost   //If it is a different server, Then change to Ipworker.tomcat2.type=ajp13worker.tomcat2.lbfactor = 1#========tomcat3========worker.tomcat2.port= 13009worker.tomcat2.host=192.168.10.250worker.tomcat2.type=ajp13worker.tomcat2.lbfactor = 1 #========controller, Load Balancer Controller ========WORKER.CONTROLLER.TYPE=LBWORKER.CONTROLLER.BALANCED_WORKERS=TOMCAT1,TOMCAT2,TOMCAT3     // How many tomcat to add how many worker.controller.sticky_session=false     //If it is true/1, it means that when the user is first treated by a server, Then it's all worker.controller.sticky_session_force=1#worker.controller.sticky_session=1.

6. Next to the Conf folder of the Tomcat installation path for each server, locate Serve.xml and change the following location information:

Note: 1.port and Jvmroute must correspond to the Workers.properties; 2. Note Whether it is commented out (The last red box is easy to ignore).

7. Add <distributable/> after each tomcat below the <display-name> of Web. Xml that needs to be created with the Java designer.

8. Create a new test page in the project test.jsp:

<%@ page contenttype= "text/html; CHARSET=GBK "%><%@ page import=" java.util.* "%>

In the case of a successful test, enter a value in the name and value input box, followed by server info, without changing the ID, and Tomcat will change.

10. If you are doing a standalone deployment of finereport, you will need to copy the Webreport of FR overall to the webapps of Tomcat, and you will need to copy the same webreport under each tomcat, then remove the web-inf-- The LIC under resources (in the case of already registered), is registered through the Localhost:8080/webreport/reportserver Access decision system. (each server corresponds to a different. Lic)

11. Modify the following Web. XML (Seventh Step) below Web-inf in the Tomcat Webreport project under each server, as follows:

<?xml version="1.0"encoding="UTF-8"? ><web-app xmlns="HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation="HTTP://JAVA.SUN.COM/XML/NS/J2EE http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"version="2.4"> <display-name>template webapp</display-name><distributable/><mime-mapping> <extension>msi</extension> <mime-type>application/x-msi</mime-type> </mime-mapping> <servlet> <servlet-name>ReportServer</servlet-name> <servlet-class>com.fr.web.reportservlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>reportserver</ Servlet-name> <url-pattern>/ReportServer</url-pattern> </servlet-mapping></web-app>

12. Under Resources, create a new CLUSTER.xml file, as follows:

<?xml version= "1.0" encoding= "UTF-8"? ><clusterconfig usecluster= "true" usershare= "true" >        // Usecluster= "true" means enable cluster configuration <ClusterService><ServiceName>A</ServiceName>  // Give this server a different alias from the other machine, registration can be arbitrary, but cannot appear the same <ip>192.168.10.249</ip>            //This server in the network IP address <port>8080</ Port>              //Report app's port <WebAppName>WebReport</WebAppName>  //Report app name, because it's Webreport project </ Clusterservice><clusterservice isself= "true" >      //isself= "True" indicates the IP current server, how many servers are added <servicename >B</ServiceName>  <ip>192.168.10.250</ip>     //above is isself, here can be localhost<port> 8080</port><webappname>webreport</webappname></clusterservice></clusterconfig>

14. Test whether the report cluster is configured successfully, you can enter it in the browser:

http://Localhost:8080/webreport/reportserver?op=fr_cluster&cmd=test_c_all

If successful, the cluster is start will be displayed, and the configuration of the entire environment is viewed through the current page information.

13. This time can be cross-access through localhost/webreport/reportserver, constantly refreshed, access to different tomcat under the Webreport project.

Note: If you are not logged into the system when you access the decision system (repeatedly prompted for input), and the user name and password are correct, you need to tick "keep logged in".

Tomcat+apache Load Balancing

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.