본문 바로가기
IT_tech/JAVA&JSP&스프링

톰캣 다중 설치

by 신드로 2019. 2. 22.

톰캣 다중 설치

 

 한 서버 내 다중 Tomcat 설치 시 필요한 메뉴얼. Tomcat 이용 시 1개의 톰캣에서 3(Tomcat내부포트, apache 연동을 위한 ajp포트,서비스 포트) 의 포트를 사용. 각 톰캣마다 포트 지정이 필요.

 

예시)

 

Tomcat1

Tomcat2

Tomcat3

Tomcat4

server port (내부)

8005

8006

8007

8008

ajp1.3 port (내부)

8009

8010

8011

8012

Connector port (외부)

8080

8090

8100

8110

 

1. 톰캣 다운로드 및 설치

1) cd /usr/local/src

 

2) wget http://mirror.apache-kr.org/ tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz

  : 해당 링크 없을 시 위 url 방문 참조하여 새 버전으로 url 수정  ex )7.0.79->7.0.81

 

3) tar zxvf apache-tomcat-7.0.79.tar.gz

  : 압축 해제

 

4) mv apache-tomcat-7.0.79 /user/local/tomcat7_1

  mv apache-tomcat-7.0.79 /user/local/tomcat7_2

 : 2개의 톰캣을 tomcat7_1, tomcat7_01에 복사하였음.

 

2. catalina.sh 경로설정

각 폴더 내 catalina.sh 파일에 노란색 부분(경로) 설정 추가

 

# resolve links - $0 may be a softlink

PRG="$0"

while [ -h "$PRG" ]; do

  ls=`ls -ld "$PRG"`

  link=`expr "$ls" : '.*-> \(.*\)$'`

  if expr "$link" : '/.*' > /dev/null; then

    PRG="$link"

  else

    PRG=`dirname "$PRG"`/"$link"

  fi

done

export CATALINA_HOME=/usr/local/tomcat7_1/apache-tomcat-7.0.79/

export TOMCAT_HOME=/usr/local/tomcat7_1/apache-tomcat-7.0.79/

export CATALINA_BASE=/usr/local/tomcat7_1/apache-tomcat-7.0.79/

CATALINA_PID=/usr/local/tomcat7_1/apache-tomcat-7.0.79//bin/tomcat.pid

# Get standard environment variables

PRGDIR=`dirname "$PRG

 

3. server.xml 포트 변경

 Server.xml 파일에 미리 정의한 포트값(노란색) 변경

-Tomcat1

<Server port="8005" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  ...

   <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    ...


    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

-Tomcat2

<Server port="18005" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  ...

   <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="18080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    ...


    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="18009" protocol="AJP/1.3" redirectPort="8443" />



각 프로젝트에 맞는 설정은 해당 폴더 내부 Server.xml, Web.xml에 별도 반영.