APACHE2.4+TOMCAT7 stand-alone vertical cluster 64-bit Windows operating system

Source: Internet
Author: User

With the current low-cost server, most of the production environment memory has reached 16G, but the Java operating environment, the maximum can only stay in 2G, which caused the waste of the server resources, so the vertical cluster of a single machine is too necessary! This article needs to have Windows operational fundamentals and Java EE Fundamentals

Most of the production environment is Linux operating system, in view of the convenience of blogging, I can only in their own computer dedicated to the Win7 64-bit operating system to demonstrate the deployment method of the cluster, of course, in Windows and Linux deployment cluster is similar, we focus on methods and steps, OK, Formal entry question!

Because I am a 64-bit operating system, so this article is used in 64-bit software, remember that there is no 32-bit software, otherwise there will be a problem (I have encountered!). )。

1. Software Preparation

Apache HTTP Server 2.4--> official website:http://www.apache.org/

JDK8 64--Official website:http://www.java.com/zh_CN/

tomcat_7             -Official website: http://tomcat.apache.org/

MOD_JK--Official website: http://tomcat.apache.org/ Download under the heading find Tomcatconnec Tors Link Entry , looks like a unix/linux under the dynamic library, actually should be a Win32 DLL the dynamic Library, which is probably to maintain the consistency of the different platform configurations, only uses this extension (*.so).

Apache HTTP Server 2.4 and JDK8 64 bits are installed version of the software, the other is the decompression version of the software.

2. Directory Preparation and Software installation

Create directory: E:\soft\apache_jiqun

Apache HTTP Server 2.4 is installed in this directory

tomcat_7 extract two copies, put it in the directory

The prepared results are as follows:

JDK8 64-bit according to normal installation, but need to configure environment variables, java_home, and path

MOD_JK extracted after so file, renamed to Mod_jk.so, and placed in the. \ apache2.4\modules Directory

3. Software configuration-Load Balancer 3.1 Modify Apache configuration file http.conf

Locate the http.conf in the Conf directory under the Apache installation directory and add the following sentence to the file at the end.

include conf/mod_jk.conf

3.2 http.conf The same directory, create the mod_jk.conf file with the following contents:

LoadModule Jk_module modules/mod_jk.so

Jkworkersfile conf/workers.properties

Jkmount/* Controller

The meanings were:

Loading the mod_jk.so module

Load the mod_jk.so configuration file

Specify those requests to be given to Tomcat processing, "controller" for the load assignment controller specified in workers.propertise (e.g. JSP file: Jkmount/*.jspcontroller)

3.3 http.conf The same directory, create the Workers.properties file,The contents are as follows:

Worker.list = Controller,tomcat1,tomcat2

#========tomcat1========

worker.tomcat1.port=8009

Worker.tomcat1.host=localhost

Worker.tomcat1.type=ajp13

Worker.tomcat1.lbfactor=1

#========tomcat2========

worker.tomcat2.port=8109

Worker.tomcat2.host=localhost

Worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor=2

#========controller========

Worker.controller.type=lb

Worker.controller.balanced_workers=tomcat1,tomcat2

Worker.controller.sticky_session=1

The meanings were:

Worker.list:server List

WORKER.TOMCAT1.PORT:AJP13 port number, server.xml configuration under Tomcat, default 8009

Worker.tomcat1.host:tomcat host address, if not for this machine, please fill in the IP address

Worker.tomcat1.lbfactor:server weighted weight, the higher the value, the more requests to be divided

Worker.controller.balanced_workers: Specify tomcat to share requests

3.4 Modifying the Tomcat configuration file Server.xml

If you are a horizontal cluster, which is installed on a different computer Tomcat,tomcat the number of installations is one, so you don't have to modify Tomcat configuration file . I'm here to install two Tomcat on the same computer , with a vertical cluster, so one of the settings must be modified to avoid port collisions

1)will closeTomcatThe listening port is changed from8005instead8105
that the
<server port= "8005"shutdown=" > "Shutdown "
instead
<server port= "8105"shutdown=" > "Shutdown "

2)Change the HTTP service port number from 8080 to 8180
Find
<!--Define a non-ssl http/1.1connector on port 8080--
<connector port= "8080" 
put the 8080 here.Switch8180

3)Change the AJP port number from 8009 to 8109
Find
<!--Define an AJP 1.3 Connector onport 8009--
<connector port= "8009"
put the 8009 here.Switch8109

4). Write a test JSP
Create a directory test, which creates a new test.jsp with the content :

<%

System.out.println ("===========================" + Session.getid ());

%>

the directory Test put in TOMCAT1,TOMCAT2 of the WebApps under

5). Start Apache,tomcat1,tomcat2, to test

through http://localhost/test/test.jsp visit, refresh a few more pages, viewTOMCAT1and theTOMCAT2window, you will be able to see a line of printed lines"===========================94cefc2684dfabf2bb3960ce7aa87367 ", and statistically speaking, aboutTOMCAT2the number of prints is inTOMCAT1and each control window is twice timesplayed bySessionnot consistent. You can see that the request will beTOMCAT1,TOMCAT2shunt processing According to different weights,Enables load Balancing

4. Software configuration-Configure cluster, session copy

&NBSP; Configure load balancing only yet, and session copy, which means any one of them tomcat " added session tomcat in the cluster tomcat session

4.1 Modify TOMCAT1, Tomcat2 of the Server.xml, The cluster section is configured to add the following to the <Cluster> node of the comment: (note that the Receiver port is changed to 4001 in TOMCAT2)

<clusterclassname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster" >

<managerclassname= "Org.apache.catalina.ha.session.DeltaManager"

Expiresessionsonshutdown= "false"

Notifylistenersonreplication= "true"/>

<channelclassname= "Org.apache.catalina.tribes.group.GroupChannel" >

<membershipclassname= "Org.apache.catalina.tribes.membership.McastService"

Address= "228.0.0.4"

Port= "45564"

Frequency= "500"

Droptime= "/>"

<receiverclassname= "Org.apache.catalina.tribes.transport.nio.NioReceiver"

address= "Auto"

port= "4000" <!-- Note that TOMCAT2 , the ports in this section are changed to 4001 --

autobind= "100"

selectortimeout= "5000"

maxthreads= "6"/>

<senderclassname= "Org.apache.catalina.tribes.transport.ReplicationTransmitter" >

<transportclassname= "Org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

</Sender>

<interceptorclassname= "Org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

<interceptorclassname= "Org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>

</Channel>

<valveclassname= "Org.apache.catalina.ha.tcp.ReplicationValve"

Filter= ". *.gif|. *.js|. *.jpeg|. *.jpg|. *.png|. *.htm|. *.html|. *.css|. *.txt "/>

<valveclassname= "Org.apache.catalina.ha.session.JvmRouteBinderValve"/>

<deployerclassname= "Org.apache.catalina.ha.deploy.FarmWarDeployer"

Tempdir= "/tmp/war-temp/"

Deploydir= "/tmp/war-deploy/"

Watchdir= "/tmp/war-listen/"

Watchenabled= "false"/>

<clusterlistenerclassname= "Org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>

<clusterlistener classname= "Org.apache.catalina.ha.session.ClusterSessionListener"/>

</Cluster>

4.2 Configuring Session Replication

in the Test directory under new Web-inf directory, Web-inf under New Web. XML, The contents are as follows

<web-appxmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version= "2.4" >

<display-name>test</display-name>

<distributable/>

</web-app>

4.3 Test session consistency

through http://localhost/test/test.jsp Access, the number of times to refresh the page, in the console printing the session value is consistent.

Concluding remarks: I've been trying to make a few days ago WebSphere cluster, but WebSphere is really a monster, and free download also lacks a lot of features, and also have a trial period!!! Really uncomfortable, then I also want to understand, what the cluster is not to engage, the focus is to master the principle of vertical cluster and the need for the scene. These configurations are the same, but the configuration page is not the same, but we can according to their knowledge and the WebSphere Company to communicate with it not?! So when in the future at work even meet the needs of WebSphere cluster is not afraid!


This article uses the software, I also put in my download channel, welcome to download!

Learn from the article:

http://blog.csdn.net/kypfos/article/details/3081330

Http://blog.chinaunix.net/uid-26184465-id-3761118.html

Apache2.4+tomcat7 stand-alone vertical cluster 64-bit Windows operating system

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.