리눅스에 깔려있는 아파치 톰캣을 윈도우 PC에서 모니터링해 보는 방법을 알아본다.

1. 톰캣 버전 확인

아파치 톰캣 버전이 9.0대면 이미 JMX remote가 내장되어 있지만, 그 아래 버전이면 홈페이지가서 다운 받아야 한다.

https://tomcat.apache.org/download-80.cgi

 

Apache Tomcat® - Apache Tomcat 8 Software Downloads

Welcome to the Apache Tomcat® 8.x software download page. This page provides download links for obtaining the latest versions of Tomcat 8.x software, as well as links to the archives of older releases. Unsure which version you need? Specification versions

tomcat.apache.org

 

본인컴퓨터에 깔려있는 톰캣 버전을 확인하려면 tomcat/bin 폴더에 가서 아래 명령어를 입력하면 된다.

$./catalina.sh version

참고로 카탈리나 명령어를 통해 start, stop도 할 수 있다.

 

2. catalina.sh 설정

catalina.sh에 바로 jmx remote 설정 문구를 넣는 케이스도 있는데, 그냥 서버 ip와 port만 넣어주는 것으로 한다.

catalina.sh는 tomcat/bin 폴더 에 있다.

 

catalina.sh

serverIP="10.26.10.110"
remotePORT=9090
rmiPORT=9091

여기서 서버IP는 모니터링 프로그램 VMVisual을 실행시키는 서버가 아니라 톰캣이 돌아가고 있는 서버의 IP이다.

 

 

3. setenv.sh

bin폴더 안에 setenv.sh를 만들어서 아래와 같이 써준다.

 

########JMX remote start########


# OOM 발생시 /home/heapdump 에 heapdump 뜨고 GC 로그 남도록 설정
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/heapdump -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/home/tomcat_8080/logs/gc.log -XX:+UseGCLogFileRotation -XX:GCLogFileSize=2m -XX:NumberOfGCLogFiles=100"

export JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Djava.rmi.server.hostname=${serverIP}
-Dcom.sun.management.jmxremote.port=${remotePORT}
-Dcom.sun.management.jmxremote.rmi.port=${rmiPORT}
-Dcom.sun.management.jmxremote.ssl=false "
CATALINA_OPTS="${JMX_OPTS} ${CATALINA_OPTS}"

#########JMX END###############

setenv.sh는 catalina가 실행될 때 저절로 불러오게끔 코딩되어 있다.

 

4. 톰캣 실행

./catalina.sh start 또는 systemctl start tomcat으로 톰캣을 실행한다.

 

5. 연결

VMvisual을 실행하여 Add remote에 가서 해당 Host와 Port를 써준다.

실제로 연결되는지 확인하려면 Jconsole을 사용해도 무방하다.

 

+ Recent posts