Lamt based on MOD_JK configuration using the steps detailed

Source: Internet
Author: User
Tags keep alive tomcat

Mod_jk
Configure Apache to connect to Tomcat through the MOD_JK module
MOD_JK is an ASF project, is a work on the Apache side based on the AJP protocol and Tomcat Communication connector, it is a module of Apache, is the AJP protocol client (server is Tomcat AJP connector).

[Root@nginx-proxy2 conf.d]# CD
[Root@nginx-proxy2 ~]# Tar XF tomcat-connectors-1.2.40-src.tar.gz
[Root@nginx-proxy2 ~]# CD tomcat-connectors-1.2.40-src/native/
[Root@nginx-proxy2 native]# rpm-ql httpd-devel|grep apxs
Ensure APXS exists and ensure Httpd-devel installation

[Root@nginx-proxy2 native]# yum-y Install Httpd-devel
[Root@nginx-proxy2 native]# rpm-ql httpd-devel|grep apxs
/usr/sbin/apxs
/usr/share/man/man8/apxs.8.gz
[Root@nginx-proxy2 native]#
[Root@nginx-proxy2 native]#./configure--with-apxs=/usr/sbin/apxs
[Root@nginx-proxy2 native]# make && make install
Make sure mod_jk.so exists

[Root@nginx-proxy2 modules]# ls/usr/lib64/httpd/modules/|grep mod_jk
Mod_jk.so
[Root@nginx-proxy2 modules]#
To edit a configuration file:

[Root@nginx-proxy2 conf.d]# Cat mod_jk.conf
LoadModule Jk_module modules/mod_jk.so
Jkworkersfile/etc/httpd/conf.d/workers.properties
Jklogfile Logs/mod_jk.log
Jkloglevel Debug
Jkmount/* Tomcata
Jkmount/jkstatus/stat-linuxea
Edit workers.properties! because it is mod_jk, use Ajp,so, port is 8009,

[Root@nginx-proxy2 conf.d]# Cat Workers.properties
Worker.list=tomcata,stat-linuxea
Worker. tomcata.port=8009
Worker. tomcata.host=10.0.0.53
Worker. Tomcata.type=ajp13
Worker. Tomcata.lbfactor=1
Worker.stat-linuxea.type = Status
[Root@nginx-proxy2 conf.d]# pwd
/etc/httpd/conf.d
[Root@nginx-proxy2 conf.d]#
To see if the log is normal:

[Root@nginx-proxy2 conf.d]# tail/var/log/httpd/mod_jk.log
[Thu Feb 18 06:13:02.200 2016] [7,345:139,943,077,504,992] [Debug] Ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 03d0    6E 3 A 20 23 44 32 41 34 31 43 3 b 0A 20 -und:. #D2A41C;
[Thu Feb 06:13:02.200 2016] [7345:139943077504992] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c ( 1403): 03e0    7D 0A 65 -}...td.header-le
[Thu Feb 18 06: "2E"-----------------2D 6C- 13:02.200 2016] [7345:139943077504992] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1403): 03f0     7B 0A 6c -Ft.{.....text-al
[Thu Feb 18 06:13:02.201 2016] [C] [ 7345:139943077504992] [Debug] ws_write::mod_jk.c (552): written 8065 out of 8065
[Root@nginx-proxy2 conf.d]#
Jk_m Change log level after OD is normal: jkloglevel notice

[Root@nginx-proxy2 conf.d]# cat mod_jk.conf
loadmodule  jk_module  modules/mod_jk.so
jkworkersfile /etc/httpd/conf.d/workers.properties
jklogfile  logs/mod_jk.log
JkLogLevel  Notice
jkmount /*  tomcata
jkmount /jkstatus/  stat-linuxea
[Root@nginx-proxy2 conf.d]#
Normal while viewing

[Root@nginx-proxy2 conf.d]# tail/var/log/httpd/mod_jk.log
[Thu Feb 18 06:17:19.447 2016] [7,346:139,943,077,504,992] [Debug] Jk_shm_close::jk_shm.c (m): Closed shared memory/etc/httpd/logs/jk-runtime-status.7337 childs=8
[Thu Feb 06:17:19.448 2016] [7345:139943077504992] [debug] JK_SHM_CLOSE::JK_SHM.C (m): Closed shared memory/etc/httpd/logs/ jk-runtime-status.7337 childs=7
[Thu Feb 06:17:19.449 2016] [7344:139943077504992] [debug] Jk_shm_close::jk_ SHM.C (m): Closed shared memory/etc/httpd/logs/jk-runtime-status.7337 childs=6
[Thu Feb 18 06:17:19.451 2016] [7343 : 139943077504992] [debug] jk_shm_close::jk_shm.c: Closed shared
[Root@nginx-proxy2 conf.d]#
If it is a compilation installation, WITH-APXS specifies the appropriate location to

[Root@nfs-web1 native]#./configure--with-apxs=/usr/local/apache/bin/apxs
[Root@nfs-web1 native]# make && make install
The description is as follows:
To use the MOD_JK connector, Apache needs to load this connector module at startup. To facilitate the management of the configuration associated with the MOD_JK module, a dedicated profile/etc/httpd/extra/httpd-jk.conf is used to save the instructions and their settings. Its contents are as follows:

# Load The MOD_JK
LoadModule Jk_module modules/mod_jk.so
Jkworkersfile/etc/httpd/extra/workers.properties
Jklogfile Logs/mod_jk.log
Jkloglevel Debug
Jkmount/* Tomcata
Jkmount/status/stat1
In addition to the need to use the loadmodule instruction to load the module in Apache, MOD_JK also needs to set some other instructions in the Apache main configuration file to configure its working properties. If Jkworkersfile is used to specify a configuration file that holds the definition of worker-related work attributes, Jklogfile is used to specify the log file for the MOD_JK module, and jkloglevel can be used to specify the level of the log (info, error, Debug), In addition, you can use Jkrequestlogformat to customize the logging Information format. The Jkmount (format: jkmount) specifies the corresponding relationship between the URL and the Tomcat workers.

In order for Apache to use the configuration information in the/etc/httpd/extra/httpd-jk.conf configuration file, you need to edit/etc/httpd/httpd.conf and add the following line:
Include/etc/httpd/extra/httpd-jk.conf

For the Apache proxy, the engine in each back-end tomcat instance can be viewed as a worker, and information about each worker's address, connector's port, and so on is specified on the Apache side so that Apache can identify and use the worker. Traditionally, the files that are configured for this information are usually workers.properties, and the specific path is specified using the Jkworkersfile described earlier, and MOD_JK scans the file for the configuration information for each worker when Apache starts. For example, we use/etc/httpd/extra/workers.properties here.

Workers.properties files typically consist of two classes of instructions: One is the list of worker names that MOD_JK can connect to, and the other is the attribute configuration information for each worker. They follow the following syntax, respectively.

Worker.list = < A comma separated list of worker names >
Worker. <worker name> .<property> = <property value>
Where the worker.list instruction can be specified repeatedly, and worker name is the value of the engine component Jvmroute parameter in Tomcat. Such as:
Worker. tomcata.host=172.16.100.1

Depending on how it works, there are a number of different types of worker, a property woker that needs to be defined for each worker. Type The common types are as follows:
◇AJP13: This type indicates that the current worker is a running Tomcat instance.
◇LB:LB, the load balancing, is dedicated to Woker in a load-balancing scenario; This worker is not really responsible for processing user requests, but rather dispatching user requests to other types of worker who are ajp13.
◇status: The user displays special worker for each actual worker working status in a distributed environment, it does not process any requests, nor does it relate to any actual worker instances. For example, see the configuration in the following article.

Other common attribute descriptions for worker:
The host where the worker instance of ◇host:tomcat 7 resides;
The port of the AJP1.3 connector on the ◇port:tomcat 7 instance;
◇connection_pool_minsize: The minimum number of connections to keep in the connection pool; default is POOL_SIZE/2;
◇connection_pool_timeout: The super time length of connection in the connection pool;
◇mount: The context path provided by the current worker, if there are more than one, uses the space to open; This property can be overridden by a jkmount instruction;
◇retries: Number of retries when the error occurred;
◇SOCKET_TIMEOUT:MOD_JK wait for the worker response time length, the default is 0, that is, infinite wait;
◇socket_keepalive: Keep Alive is enabled, 1 means enabled, 0 is disabled;
The weight of the ◇lbfactor:worker, which can be defined for the worker in a load-balanced application scenario;

In addition, in load-balancing mode, the proprietary properties are:
◇balance_workers: A list of names for each worker in a load-balancing pattern, and it should be noted that The worker name that appears here must not be defined in any Worker.list property list, and the worker name defined in the Worker.list attribute must contain load-balanced worker. For a specific example, see the definition in the following article.
◇method: Can be set to R, T or B; The default is R, which is scheduled according to the number of requests; t means scheduling according to the actual flow size already sent to the worker; B means scheduling according to actual load.
◇sticky_session: After a request is dispatched to a worker, all subsequent requests originating from this address are dispatched directly to the worker, which binds the user session to a worker. The default value is 1, which enables this feature. This property value can be set to 0 if session replication is supported between the worker on the back end.

As specified in the previous article,/etc/httpd/extra/workers.properties is used here to define a worker named Tomcata and assign it several properties. The contents of the document are as follows:

WORKER.LIST=TOMCATA,STAT1
Worker. tomcata.port=8009
Worker. tomcata.host=172.16.100.1
Worker. TOMCATA.TYPE=AJP13
Worker. Tomcata.lbfactor=1
Worker.stat1.type = status
The configuration of a worker communication based on the MOD_JK module and the backend name Tomcata has been completed, and the restart of the HTTPD service will take effect

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.