Apache Load Balancer Session sticker configuration (JK mode)

Source: Internet
Author: User
Tags knowledge base port number tomcat

Apache Load Balancer Session sticker configuration (JK mode)

In the work, because other products and Apache reverse proxy mode of work is not very good, so need to put Apache and Application Server (TOMCAT) co-configuration of a long MOD_JK mode of the session paste pattern, in the configuration process, or encountered some problems, mainly forget to modify Tomcat The name of the Jvmroute in/conf/server.xml, causing the session paste to remain unsuccessful. The following is an example of how Apache works with IP for "192.168.3.119" and "192.168.3.116" on two machines, using the configuration Apache and app integration as examples. 1.1 Apache and JK Settings 1.1.1 Open mod_jk module and block app requests

Open the Apache installation directory of the conf/httd.conf file, add the following code at the end of the file (if you have previously used other ways to configure Apache integration with the app, you need to remove the relevant configuration, if not, add the following configuration directly). Here Apache configuration port is 81,apache default configuration port is 80, in actual use need to replace with Apache listening port.

In this example, a request for all Webpic apps is configured, and the address of the Webpic app needs to be replaced with the actual address (this is a capture app for a picture, and if no picture is obtained, the configuration of the webpic can be removed). The following Red Font section is a place to note, as follows:

#加载mod_jk Module

LoadModule Jk_module modules/mod_jk.so

#指定appbalancer_jk the. properties file path.

#如果apache的conf目录下没有该配置文件, it is created. See the following section for details

Jkworkersfile conf/appbalancer_jk.properties

<virtualhost *:81>

AddType text/javascript. js

AddType text/css;. css

AddType text/html;charset=utf-8. html

ServerName my.app.com

ServerAdmin test@sina.com.cn

#webpic, Request static resources.

Alias/webpic "D:\APPV7005\WCMData\webpic"

<directory "D:\APPV7005\WCMData\webpic" >

Options-indexes multiviews FollowSymLinks includes

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

#指定那些请求交给tomcat处理

Jkmount/app/services appbalance

Jkmount/app/*.* Appbalancer

Jkmount/*.do Appbalancer

Jkmount/app Appbalancer

Jkmount/app/appbalancer

JKMOUNT/APP/SD Appbalancer

</VirtualHost>

If Apache does not compile the mod_jk.so module at compile time, it can go to the official Apache website to download, mod_jk download the following address:

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

after entering the URL, according to your Apache installed operating system to download, if it is a Linux system, then click on the Linux link, according to the version of Apache select the appropriate mod_jk.so file to download. 1.1.2 Setting up appbalancer_jk.properties files

Open the "appbalancer_jk.properties" file in the Conf directory (if the file does not exist, create a new file), and fill in the file with the following content. We simply replace the IP address and port number in the file with the actual IP address of the app and the AJP communication port. The Red font section is where we need to replace it, as in the table below. M119 and m116 are the Jvmroute names of the app servers, respectively, as described in the next section configuration.

#server list. Mxxx is the name of the node, and the number of nodes is set to a few

worker.list=appbalancer,m119,m116

#ajp13 port number, server.xml configuration under Tomcat, default 8009

#tomcat的主机地址, if not for this machine, please fill in the IP address

#server的加权比重, the higher the value, the more requests are to be divided.

#可以将主节点的比重设置为小一点的值

#========m119========

worker.m119.port=8009

worker.m119.host=192.168.3.119

Worker.m119.type=ajp13

worker.m119.lbfactor=2

#========m116========

worker.m116.port=8009

worker.m116.host=192.168.3.116

Worker.m116.type=ajp13

Worker.m116.lbfactor=3

#========appbalancer, Load Balancer controller ========

Worker.appbalancer.type=lb

worker.appbalancer.balance_workers=m119,m116

Worker.appbalancer.sticky_session=true

1.1.3 Modifying Tomcat's Server.xml

Here is an example of an app server Tomcat, open the Tomcat/conf/server.xml file, locate the following configuration, and add the red sub-area below. The Jvmroute needs to match the name of the worker in the "appbalancer_jk.properties" file.

<!--    Define the top level container with our cont Ainer Hierarchy-

<Engine    name= "Catalina" defaulthost= "localhost" jvmroute= "m116" >

It is important to note that "m116" needs to be filled out according to the actual situation, usually named "M" plus the IP address where the knowledge base resides. If IP is "192.168.3.116", then Jvmroute can be named "m116". Unified naming, easy to manage.

Note:

This section takes two app nodes as an example, you need to open the Tomcat/conf/server.xml file for two apps separately, Jvmroute set to "m116" and "m119 ", the Jvmroute name of each app cannot be the same.

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.