1. 개요

공석 문서 : http://tomcat.apache.org/connectors-doc/

Tomcat Connectors는 Tomcat을  앞 단의 Apache 등의 웹 서버와 연결 할 수 있게 해 주는 모듈이다. Apache JServer Protocol을 사용하며, 연결 가능한 웹 서버는 Apache, iPlanet, IIS 등이다.


2. 사전 작업

Tomcat Connector의 설치라는 것은, 앞단의 Apache HTTP Server와의 연동을 위하여 Connector를 컴파일하는 과정이다. 이 작업은 HTTP Server가 설치된 서버에서 수행한다.

우선 Connector를 다운로드 받는다.  Connector 버전은 1.2.37이다. (2014년 1월 말) Connector 버전은 1.2.41이다. (2016년 4월 초)

wget http://www.apache.org/dist/tomcat/tomcat-connectors/jk/${FILE_NAME}.tar.gz
FILE_NAME=tomcat-connectors-1.2.37-src
gzip -d ${FILE_NAME}.tar.gz
tar -xvf ${FILE_NAME}.tar

3. 컴파일

컴파일을 한다. 물론 Aapache HTTP Server는 미리 설치되어 있어야 한다.

cd ${FILE_NAME}/native
./configure --with-apxs=${SVC_DIR}/http/${HTTP_VER}/bin/apxs
make
make install

만일 컴파일 작업이 수월하지 않은 경우, 바이너리를 다운로드 받을 수도 있다.

-> http://apache.mirror.cdnetworks.com//tomcat/tomcat-connectors/jk/binaries/ 


3. 설정

우선 httpd.conf에 mod_jk 설정 파일을 include한다.

3-1. httpd.conf

echo "Include servers/${INST_NAME}/conf/extra/httpd_mod_jk.conf" >> httpd.conf

3-2. http_mod_jk.conf

LoadModule jk_module    modules/mod_jk.so

<IfModule mod_jk.c>
        JkWorkersFile servers/#INST_NAME#/conf/extra/workers.properties
#       JkLogFile "|bin/rotatelogs servers/#INST_NAME#/logs/mod_jk.log.%Y.%m.%d 86400"
        JkLogLevel error
        JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
        JkShmFile servers/#INST_NAME#/logs/jk.shm
        JkMountFile servers/#INST_NAME#/conf/extra/uriworkermap.properties
</IfModule>

<Location /jkstatus/> jkmount jkstatus Order deny,allow #Deny from all allow from all
</Location>

3-3. workers.properties

worker.list=lb_pets,jkstatus

worker.node_pets_11.type=ajp13
worker.node_pets_11.host=192.168.1.238
worker.node_pets_11.port=8009
worker.node_pets_11.lbfactor=1
worker.node_pets_11.socket_timeout=300
worker.node_pets_11.socket_keepalive=True
worker.node_pets_11.connect_timeout=20000
worker.node_pets_11.connection_pool_size=64
worker.node_pets_11.connection_pool_minsize=32
worker.node_pets_11.connection_pool_timeout=60

worker.node_pets_21.type=ajp13
worker.node_pets_21.host=192.168.1.239
worker.node_pets_21.port=8109
worker.node_pets_21.lbfactor=1
worker.node_pets_21.socket_timeout=300
worker.node_pets_21.socket_keepalive=True
worker.node_pets_21.connect_timeout=20000
worker.node_pets_21.connection_pool_size=64
worker.node_pets_21.connection_pool_minsize=32
worker.node_pets_21.connection_pool_timeout=60

worker.lb_pets.type=lb
worker.lb_pets.balance_workers=node_pets_11,node_pets_21
worker.lb_pets.sticky_session=1
worker.jkstatus.type=status

3-4. uriworkermap.properties

/*|/=lb_pets
!/*.html=lb_pets
!/images|/*=lb_pets
!/jmx-console|/*=lb_pets
!/web-console|/*=lb_pets
!/admin-console|/*=lb_pets
!/server-status|/*=lb_pets

4. 오류 해결

Tomcat Connector 컴파일 시 만약 다음과 같은 오류가 발생한다면,

CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /sw/httpd/tomcat-connectors/1.2.41/module/native/scripts/build/unix/missing aclocal
configure.ac:164: warning: macro `AM_PROG_LIBTOOL' not found in library
 cd . && /bin/sh /sw/httpd/tomcat-connectors/1.2.41/module/native/scripts/build/unix/missing automake --foreign
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /sw/httpd/tomcat-connectors/1.2.41/module/native/scripts/build/unix/missing autoconf
configure.ac:154: error: possibly undefined macro: AC_PROG_LD
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:160: error: possibly undefined macro: AC_LIBTOOL_DLOPEN
configure.ac:162: error: possibly undefined macro: AM_PROG_LIBTOOL
make: *** [configure] Error 1
ERROR:   is failed. Check arguments.
compile is failed. Check the arguments..!!

libtool 패키지를 설치하여 해결할 수 있다.

# yum install libtool
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: data.nicehosting.co.kr
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
Resolving Dependencies
--> Running transaction check
---> Package libtool.x86_64 0:2.2.6-15.5.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
 Package                        Arch                          Version                                Repository                   Size
=======================================================================================================================================
Installing:
 libtool                        x86_64                        2.2.6-15.5.el6                         base                        564 k

Transaction Summary
=======================================================================================================================================
Install       1 Package(s)

Total download size: 564 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
libtool-2.2.6-15.5.el6.x86_64.rpm                                                                               | 564 kB     00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libtool-2.2.6-15.5.el6.x86_64                                                                                       1/1
  Verifying  : libtool-2.2.6-15.5.el6.x86_64                                                                                       1/1

Installed:
  libtool.x86_64 0:2.2.6-15.5.el6

Complete!