[Tomcat] 멀티 인스턴스 설치 방법


[ 알아야 하는 개념 ]


- CATALINA_HOME : Tomcat 설치 디렉토리 경로

- CATALINA_BASE : 인스턴스의 구성 디렉토리 경로 (인스턴스 개수만큼 생성가능, 따로 지정하지 않으면 CATALINA_HOME 과 동일)


- 싱글 인스턴스 : 기본적으로 CATALINA_HOME, CATALINA_BASE 는 동일한 디렉토리를 가진다.

- 멀티 인스턴스 : 하나의 PC 에서 여러 Tomcat 인스턴스를 실행해야 하는 경우 CATALINA_BASE 를 수동으로 지정을 한다. (아래와 같은 이점이 있다.)

1. Tomcat 버전 업그레이드 관리가 쉬워짐
2. 동일한 .jar 파일의 중복을 피한다.
3. setenv 쉘과 같은 설정파일을 공유할 수 있다.


- setenv.sh, setenv.bat : 톰캣 구동 시 로드할 환경설정 (톰캣 설치 시 기본적으로 없음, 추가로 생성해 줘야하는 파일)


[ CATALINA_BASE 의 내용 ]

아래의 디렉토리 구조를 고려하고 생성한다. 권장 디렉토리를 모두 생성하지 않으면 Tomcat 이 자동으로 디렉토리를 생성한다.

권한문제와 같이 필요한 디렉토리를 만들지 못하면 Tomcat 시작하지 않거나 올바르게 동작하지 않을 수 있다.

1. bin 디렉토리 : setenv.sh, setenv.bat, tomcat-juli.jar 파일
 - 권장 : X
 - 순서 : CATALINA_BASE 먼저 로드, 파일 없으면 CATALINA_HOME 에서 로드

2. lib 디렉토리 : classpath 추가할 리소스가 있는 경로
 - 권장 : O, Application 이 외부 라이브러리를 참조하는 경우
 - 순서 : CATALINA_BASE 먼저 로드 후 CATALINA_HOME 이 두번째로 로드

3. logs 디렉토리 : 인스턴스별 로그파일 디렉토리
 - 권장 : O  => 필수 : O

4. webapps 디렉토리 : 자동으로 로드되는 Web Application 이 있는 디렉토리
 - 권장 : O
 - 순서 : CATALINA_BASE 만 해당함

5. work 디렉토리 : 배포된 웹 애플리케이션의 임시 작업 디렉토리
 - 권장 : O

6. temp 디렉토리 : JVM이 임시파일을 저장하는데 사용하는 디렉토리
 - 권장 : O

7. conf 디렉토리 : Tomcat 설정파일 디렉토리
 - 필수 : O, 최소한 server.xml, web.xml 파일은 있어야 한다.
 - CATALINA_HOME/conf 에서 모든 구성파일을 디렉토리로 복사하는것을 추천
 - 순서 : CATALINA_BASE 먼저 로드, 파일 없으면 CATALINA_HOME 에서 로드



[ 환경 ]

- JDK : OPEN_JDK_17

- Tomcat : Tomcat-11.0.2

- 설치 경로 : /home/1004lucifer/tomcat/



[ 구조 - 작업 결과 ]

[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total 13892
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--. 1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
lrwxrwxrwx. 1 1004lucifer 1004lucifer 20 Dec 14 21:58 engine -> apache-tomcat-11.0.2
drwxrwxr-x. 4 1004lucifer 1004lucifer 42 Dec 14 21:59 instances
-rwxr-xr-x. 1 1004lucifer 1004lucifer 211 Dec 14 22:01 shutdown.sh
-rwxr-xr-x. 1 1004lucifer 1004lucifer 210 Dec 14 22:01 startup.sh
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ cat shutdown.sh
#!/bin/bash

export JAVA_HOME=/usr/lib/jvm/jre-17
export CATALINA_HOME=/home/1004lucifer/tomcat/engine
export CATALINA_BASE=/home/1004lucifer/tomcat/instances/$1

/home/1004lucifer/tomcat/engine/bin/shutdown.sh
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ cat startup.sh
#!/bin/bash

export JAVA_HOME=/usr/lib/jvm/jre-17
export CATALINA_HOME=/home/1004lucifer/tomcat/engine
export CATALINA_BASE=/home/1004lucifer/tomcat/instances/$1

/home/1004lucifer/tomcat/engine/bin/startup.sh
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ tree instances/
instances/
├── instance_1
│   ├── conf
│   │   ├── Catalina
│   │   │   └── localhost
│   │   ├── catalina.properties
│   │   ├── context.xml
│   │   ├── jaspic-providers.xml
│   │   ├── jaspic-providers.xsd
│   │   ├── logging.properties
│   │   ├── server.xml
│   │   ├── tomcat-users.xml
│   │   ├── tomcat-users.xsd
│   │   └── web.xml
│   ├── logs
│   │   ├── catalina.2024-12-14.log
│   │   ├── catalina.out
│   │   └── localhost_access_log.2024-12-14.txt
│   ├── webapps
│   │   └── ROOT
│   │   └── index.html
│   └── work
│   └── Catalina
│   └── localhost
│   └── ROOT
└── instance_2
├── conf
│   ├── Catalina
│   │   └── localhost
│   ├── catalina.properties
│   ├── context.xml
│   ├── jaspic-providers.xml
│   ├── jaspic-providers.xsd
│   ├── logging.properties
│   ├── server.xml
│   ├── tomcat-users.xml
│   ├── tomcat-users.xsd
│   └── web.xml
├── logs
│   ├── catalina.2024-12-14.log
│   ├── catalina.out
│   └── localhost_access_log.2024-12-14.txt
├── webapps
│   └── ROOT
│   └── index.html
└── work
└── Catalina
└── localhost
└── ROOT

22 directories, 26 files
[1004lucifer@rhel8 tomcat]$



[ 실습 ]

[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # JDK 버전 확인
[1004lucifer@rhel8 tomcat]$ java -version
openjdk version "1.8.0_322"
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$ # JDK 17 설치 (Tomcat_11 JDK 17 이상 사용해야됨)
[1004lucifer@rhel8 tomcat]$ sudo yum install java-17-openjdk
[sudo] password
for 1004lucifer:
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Last metadata expiration check: 2:22:42 ago on Sat
14 Dec 2024 12:50:15 AM EST.
Dependencies resolved.
==========================================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================================
Installing:
java-17-openjdk x86_64 1:17.0.2.0.8-15.el8 InstallMedia-AppStream
249 k
Installing dependencies:
java-17-openjdk-headless x86_64 1:17.0.2.0.8-15.el8 InstallMedia-AppStream
41 M

Transaction Summary
==========================================================================================================================================================
Install
2 Packages

Total size:
41 M
Installed size:
190 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction
test
Transaction test succeeded.
Running transaction
Running scriptlet: java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64 1/1
Preparing : 1/1
Installing : java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64 1/2
Running scriptlet: java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64 1/2
Installing : java-17-openjdk-1:17.0.2.0.8-15.el8.x86_64 2/2
Running scriptlet: java-17-openjdk-1:17.0.2.0.8-15.el8.x86_64 2/2
Running scriptlet: java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64 2/2
Running scriptlet: java-17-openjdk-1:17.0.2.0.8-15.el8.x86_64 2/2
Verifying : java-17-openjdk-1:17.0.2.0.8-15.el8.x86_64 1/2
Verifying : java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64 2/2
Installed products updated.

Installed:
java-17-openjdk-1:17.0.2.0.8-15.el8.x86_64 java-17-openjdk-headless-1:17.0.2.0.8-15.el8.x86_64

Complete!
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13884
-rw-rw-r--. 1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # Tomcat 압축 해제
[1004lucifer@rhel8 tomcat]$ unzip apache-tomcat-11.0.2.zip
Archive: apache-tomcat-11.0.2.zip
creating: apache-tomcat-11.0.2/
creating: apache-tomcat-11.0.2/bin/
creating: apache-tomcat-11.0.2/conf/
creating: apache-tomcat-11.0.2/lib/
... (
생략)
inflating: apache-tomcat-11.0.2/webapps/manager/index.jsp
inflating: apache-tomcat-11.0.2/webapps/manager/status.xsd
inflating: apache-tomcat-11.0.2/webapps/manager/xform.xsl
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13884
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # Tomcat bin 디렉토리 이동
[1004lucifer@rhel8 tomcat]$ cd apache-tomcat-11.0.2/bin
[1004lucifer@rhel8 bin]
$
[1004lucifer@rhel8 bin]$
[1004lucifer@rhel8 bin]$
[1004lucifer@rhel8 bin]$ ll
total
924
-rw-r--r--. 1 1004lucifer 1004lucifer 31592 Dec 5 15:19 bootstrap.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 13431 Dec 5 15:19 catalina.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 21094 Dec 5 15:19 catalina.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 1703 Dec 5 15:19 catalina-tasks.xml
-rw-r--r--.
1 1004lucifer 1004lucifer 2123 Dec 5 15:19 ciphers.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1997 Dec 5 15:19 ciphers.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 25834 Dec 5 15:19 commons-daemon.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 214459 Dec 5 15:19 commons-daemon-native.tar.gz
-rw-r--r--.
1 1004lucifer 1004lucifer 2040 Dec 5 15:19 configtest.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1922 Dec 5 15:19 configtest.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 8319 Dec 5 15:19 daemon.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2091 Dec 5 15:19 digest.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1965 Dec 5 15:19 digest.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 3606 Dec 5 15:19 makebase.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 3382 Dec 5 15:19 makebase.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2096 Dec 5 15:19 migrate.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1970 Dec 5 15:19 migrate.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 3382 Dec 5 15:19 setclasspath.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 3941 Dec 5 15:19 setclasspath.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2020 Dec 5 15:19 shutdown.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1902 Dec 5 15:19 shutdown.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2022 Dec 5 15:19 startup.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1904 Dec 5 15:19 startup.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 47381 Dec 5 15:19 tomcat-juli.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 471386 Dec 5 15:19 tomcat-native.tar.gz
-rw-r--r--.
1 1004lucifer 1004lucifer 3623 Dec 5 15:19 tool-wrapper.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 4600 Dec 5 15:19 tool-wrapper.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2026 Dec 5 15:19 version.bat
-rw-r--r--.
1 1004lucifer 1004lucifer 1908 Dec 5 15:19 version.sh
[1004lucifer@rhel8 bin]
$
[1004lucifer@rhel8 bin]$ # 실팽파일에 실행권한 부여 (startup.sh, shutdown.sh 등등)
[1004lucifer@rhel8 bin]$ chmod 755 *.sh
[1004lucifer@rhel8 bin]
$
[1004lucifer@rhel8 bin]$
[1004lucifer@rhel8 bin]$ ll
total
924
-rw-r--r--. 1 1004lucifer 1004lucifer 31592 Dec 5 15:19 bootstrap.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 13431 Dec 5 15:19 catalina.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 21094 Dec 5 15:19 catalina.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 1703 Dec 5 15:19 catalina-tasks.xml
-rw-r--r--.
1 1004lucifer 1004lucifer 2123 Dec 5 15:19 ciphers.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1997 Dec 5 15:19 ciphers.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 25834 Dec 5 15:19 commons-daemon.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 214459 Dec 5 15:19 commons-daemon-native.tar.gz
-rw-r--r--.
1 1004lucifer 1004lucifer 2040 Dec 5 15:19 configtest.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1922 Dec 5 15:19 configtest.sh
-rwxr-xr-x.
1 1004lucifer 1004lucifer 8319 Dec 5 15:19 daemon.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2091 Dec 5 15:19 digest.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1965 Dec 5 15:19 digest.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 3606 Dec 5 15:19 makebase.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 3382 Dec 5 15:19 makebase.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2096 Dec 5 15:19 migrate.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1970 Dec 5 15:19 migrate.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 3382 Dec 5 15:19 setclasspath.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 3941 Dec 5 15:19 setclasspath.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2020 Dec 5 15:19 shutdown.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1902 Dec 5 15:19 shutdown.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2022 Dec 5 15:19 startup.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1904 Dec 5 15:19 startup.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 47381 Dec 5 15:19 tomcat-juli.jar
-rw-r--r--.
1 1004lucifer 1004lucifer 471386 Dec 5 15:19 tomcat-native.tar.gz
-rw-r--r--.
1 1004lucifer 1004lucifer 3623 Dec 5 15:19 tool-wrapper.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 4600 Dec 5 15:19 tool-wrapper.sh
-rw-r--r--.
1 1004lucifer 1004lucifer 2026 Dec 5 15:19 version.bat
-rwxr-xr-x.
1 1004lucifer 1004lucifer 1908 Dec 5 15:19 version.sh
[1004lucifer@rhel8 bin]
$
[1004lucifer@rhel8 bin]$
[1004lucifer@rhel8 bin]$ cd ../..
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13884
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # CATALINA_HOME 경로로 사용할 심볼릭 링크 생성 (추후 Tomcat 버전 업그레이드 용이)
[1004lucifer@rhel8 tomcat]$ ln -s apache-tomcat-11.0.2 engine
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13884
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
lrwxrwxrwx.
1 1004lucifer 1004lucifer 20 Dec 14 21:58 engine -> apache-tomcat-11.0.2
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 인스턴스들이 있을 디렉토리 생성
[1004lucifer@rhel8 tomcat]$ mkdir instances
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ cd instances/
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$ # instance_1 인스턴스 생성
[1004lucifer@rhel8 instances]$ mkdir instance_1
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$ cd instance_1/
[1004lucifer@rhel8 instance_1]
$
[1004lucifer@rhel8 instance_1]$
[1004lucifer@rhel8 instance_1]$ # Tomcat 디렉토리에서 conf 디렉토리 복사
[1004lucifer@rhel8 instance_1]$ cp -r /home/1004lucifer/tomcat/engine/conf ./
[1004lucifer@rhel8 instance_1]
$
[1004lucifer@rhel8 instance_1]$ ll
total
0
drwxr-xr-x. 2 1004lucifer 1004lucifer 215 Dec 14 21:59 conf
[1004lucifer@rhel8 instance_1]
$
[1004lucifer@rhel8 instance_1]$
[1004lucifer@rhel8 instance_1]$ cd ../
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$ ll
total
0
drwxrwxr-x. 3 1004lucifer 1004lucifer 18 Dec 14 21:59 instance_1
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$ # instance_2 인스턴스 생성 (기존 인스턴스 복사)
[1004lucifer@rhel8 instances]$ cp -r instance_1 instance_2
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$ # instance_2 인스턴스 포트 설정 변경 (셧다운:8006, Connector:8081)
[1004lucifer@rhel8 instances]$ vi instance_2/conf/server.xml
[1004lucifer@rhel8 instances]
$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$
[1004lucifer@rhel8 instances]$ cd ../
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13884
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
lrwxrwxrwx.
1 1004lucifer 1004lucifer 20 Dec 14 21:58 engine -> apache-tomcat-11.0.2
drwxrwxr-x.
4 1004lucifer 1004lucifer 42 Dec 14 21:59 instances
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 기동 스크립트 생성 (환경변수 설정 및 startup.sh 수행)
[1004lucifer@rhel8 tomcat]$ cat > startup.sh
#!/bin/bash

export JAVA_HOME=/usr/lib/jvm/jre-17
export CATALINA_HOME=/home/1004lucifer/tomcat/engine
export CATALINA_BASE=/home/1004lucifer/tomcat/instances/$1

/home/1004lucifer/tomcat/engine/bin/startup.sh
^C
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 종료 스크립트 생성 (환경변수 설정 및 shutdown.sh 수행)
[1004lucifer@rhel8 tomcat]$ cat > shutdown.sh
#!/bin/bash

export JAVA_HOME=/usr/lib/jvm/jre-17
export CATALINA_HOME=/home/1004lucifer/tomcat/engine
export CATALINA_BASE=/home/1004lucifer/tomcat/instances/$1

/home/1004lucifer/tomcat/engine/bin/shutdown.sh
^C
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ll
total
13892
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
lrwxrwxrwx.
1 1004lucifer 1004lucifer 20 Dec 14 21:58 engine -> apache-tomcat-11.0.2
drwxrwxr-x.
4 1004lucifer 1004lucifer 42 Dec 14 21:59 instances
-rw-rw-r--.
1 1004lucifer 1004lucifer 211 Dec 14 22:01 shutdown.sh
-rw-rw-r--.
1 1004lucifer 1004lucifer 210 Dec 14 22:01 startup.sh
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # startup.sh, shutdown.sh 스크립트 실행권한 추가
[1004lucifer@rhel8 tomcat]$ chmod 755 *.sh
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$ ll
total
13892
drwxr-xr-x. 9 1004lucifer 1004lucifer 220 Dec 5 15:19 apache-tomcat-11.0.2
-rw-rw-r--.
1 1004lucifer 1004lucifer 14213779 Dec 13 23:56 apache-tomcat-11.0.2.zip
lrwxrwxrwx.
1 1004lucifer 1004lucifer 20 Dec 14 21:58 engine -> apache-tomcat-11.0.2
drwxrwxr-x.
4 1004lucifer 1004lucifer 42 Dec 14 21:59 instances
-rwxr-xr-x.
1 1004lucifer 1004lucifer 211 Dec 14 22:01 shutdown.sh
-rwxr-xr-x.
1 1004lucifer 1004lucifer 210 Dec 14 22:01 startup.sh
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 호출 시 보여질 페이지 추가 (webapps/ROOT/index.html)
[1004lucifer@rhel8 tomcat]$ mkdir -p /home/1004lucifer/tomcat/instances/instance_1/webapps/ROOT
[1004lucifer@rhel8 tomcat]
$ mkdir -p /home/1004lucifer/tomcat/instances/instance_2/webapps/ROOT
[1004lucifer@rhel8 tomcat]
$ cat > /home/1004lucifer/tomcat/instances/instance_1/webapps/ROOT/index.html
====================
instance_1
====================
^C
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$ cat > /home/1004lucifer/tomcat/instances/instance_2/webapps/ROOT/index.html
====================
instance_2
====================
^C
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ ps -ef | grep java
1004luc+
46504 43597 0 22:04 pts/0 00:00:00 grep --color=auto java
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # instance_1 인스턴스 기동 (logs 디렉토리 없어서 실패, 아래 로그 확인)
[1004lucifer@rhel8 tomcat]$ ./startup.sh instance_1
Using CATALINA_BASE: /home/1004lucifer/tomcat/instances/instance_1
Using CATALINA_HOME: /home/1004lucifer/tomcat/engine
Using CATALINA_TMPDIR: /home/1004lucifer/tomcat/instances/instance_1/temp
Using JRE_HOME: /usr/lib/jvm/jre-17
Using CLASSPATH: /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar
Using CATALINA_OPTS:
touch: cannot touch
'/home/1004lucifer/tomcat/instances/instance_1/logs/catalina.out': No such file or directory
/home/1004lucifer/tomcat/engine/bin/catalina.sh: line 416: /home/1004lucifer/tomcat/instances/instance_1/logs/catalina.out: No such file or directory
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 기동 실패
[1004lucifer@rhel8 tomcat]$ ps -ef | grep java
1004luc+
46875 43597 0 22:06 pts/0 00:00:00 grep --color=auto java
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # 인스턴스 디렉토리에 logs 디렉토리 생성
[1004lucifer@rhel8 tomcat]$ mkdir /home/1004lucifer/tomcat/instances/instance_1/logs
[1004lucifer@rhel8 tomcat]
$ mkdir /home/1004lucifer/tomcat/instances/instance_2/logs
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # instance_1 인스턴스 기동
[1004lucifer@rhel8 tomcat]$ ./startup.sh instance_1
Using CATALINA_BASE: /home/1004lucifer/tomcat/instances/instance_1
Using CATALINA_HOME: /home/1004lucifer/tomcat/engine
Using CATALINA_TMPDIR: /home/1004lucifer/tomcat/instances/instance_1/temp
Using JRE_HOME: /usr/lib/jvm/jre-17
Using CLASSPATH: /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$ # Tomcat 기동됨.
[1004lucifer@rhel8 tomcat]$ ps -ef | grep java
1004luc+
46973 1 24 22:07 pts/0 00:00:01 /usr/lib/jvm/jre-17/bin/java -Djava.util.logging.config.file=/home/1004lucifer/tomcat/instances/instance_1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -classpath /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar -Dcatalina.base=/home/1004lucifer/tomcat/instances/instance_1 -Dcatalina.home=/home/1004lucifer/tomcat/engine -Djava.io.tmpdir=/home/1004lucifer/tomcat/instances/instance_1/temp org.apache.catalina.startup.Bootstrap start
1004luc+
47004 43597 0 22:07 pts/0 00:00:00 grep --color=auto java
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # instance_1 인스턴스로 접속 및 정상적으로 응답 받아오는것 확인
[1004lucifer@rhel8 tomcat]$ curl -v http://localhost:8080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::
1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 200
< Accept-Ranges: bytes
< ETag: W/"53-1734231812732"
< Last-Modified: Sun, 15 Dec 2024 03:03:32 GMT
< Content-Type: text/html
< Content-Length: 53
< Date: Sun, 15 Dec 2024 03:07:18 GMT
<
====================
instance_1
====================
* Connection #0 to host localhost left intact
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # instance_2 인스턴스 기동
[1004lucifer@rhel8 tomcat]$ ./startup.sh instance_2
Using CATALINA_BASE: /home/
1004lucifer/tomcat/instances/instance_2
Using CATALINA_HOME: /home/
1004lucifer/tomcat/engine
Using CATALINA_TMPDIR: /home/
1004lucifer/tomcat/instances/instance_2/temp
Using JRE_HOME: /usr/lib/jvm/jre-
17
Using CLASSPATH: /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$ # 인스턴스 2개 모두 정상 기동된것 확인
[1004lucifer@rhel8 tomcat]$ ps -ef | grep java
1004luc+ 46973 1 5 22:07 pts/0 00:00:01 /usr/lib/jvm/jre-17/bin/java -Djava.util.logging.config.file=/home/1004lucifer/tomcat/instances/instance_1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -classpath /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar -Dcatalina.base=/home/1004lucifer/tomcat/instances/instance_1 -Dcatalina.home=/home/1004lucifer/tomcat/engine -Djava.io.tmpdir=/home/1004lucifer/tomcat/instances/instance_1/temp org.apache.catalina.startup.Bootstrap start
1004luc+ 47063 1 16 22:07 pts/0 00:00:01 /usr/lib/jvm/jre-17/bin/java -Djava.util.logging.config.file=/home/1004lucifer/tomcat/instances/instance_2/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -classpath /home/1004lucifer/tomcat/engine/bin/bootstrap.jar:/home/1004lucifer/tomcat/engine/bin/tomcat-juli.jar -Dcatalina.base=/home/1004lucifer/tomcat/instances/instance_2 -Dcatalina.home=/home/1004lucifer/tomcat/engine -Djava.io.tmpdir=/home/1004lucifer/tomcat/instances/instance_2/temp org.apache.catalina.startup.Bootstrap start
1004luc+ 47094 43597 0 22:07 pts/0 00:00:00 grep --color=auto java
[1004lucifer@rhel8 tomcat]
$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$ # instance_2 인스턴스 접속 및 정상적으로 응답 받아오는것 확인
[1004lucifer@rhel8 tomcat]$ curl -v http://localhost:8081/
* Trying ::
1...
* TCP_NODELAY set
* Connected to localhost (::
1) port 8081 (#0)
> GET / HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 200
< Accept-Ranges: bytes
< ETag: W/"53-1734231831756"
< Last-Modified: Sun, 15 Dec 2024 03:03:51 GMT
< Content-Type: text/html
< Content-Length: 53
< Date: Sun, 15 Dec 2024 03:07:40 GMT
<
====================
instance_2
====================
* Connection #0 to host localhost left intact
[1004lucifer@rhel8 tomcat]$
[1004lucifer@rhel8 tomcat]$





댓글