티스토리 뷰

Programming/Java

TOMCAT - jmx 로 monitoring

파란크리스마스 2017. 12. 7. 23:46
728x90

출처 : 아파치 톰캣(apache tomcat) 을 jmx 로 monitoring 하기

catalina-jmx-remote.jar 파일 Tomcat이 설치된 디렉토리의 lib디렉토리에 복사

https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/extras/

$ cd /usr/local/apache-tomcat-8.5.23/lib
$ wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/extras/catalina-jmx-remote.jar

IP 확인

$ ifconfig | grep "inet addr"
          inet addr:192.168.0.24  Bcast:192.168.0.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0

setenv.sh 파일 생성

$ cd /usr/local/apache-tomcat-8.5.23/bin

setenv.sh 파일 내용

$ vi setenv.sh
  • -Dcom.sun.management.jmxremote.authenticate=false / 인증하지 않음
  • -Djava.rmi.server.hostname=192.168.0.24 / 톰캣이 구동되는 서버의 IP
  • -Dcom.sun.management.jmxremote.ssl=false / SSL 을 사용하지 않음
#!/bin/sh

JMX_OPTS=" -Dcom.sun.management.jmxremote \
                 -Dcom.sun.management.jmxremote.authenticate=false \
                 -Djava.rmi.server.hostname=192.168.0.24 \
                 -Dcom.sun.management.jmxremote.ssl=false "
CATALINA_OPTS=" ${JMX_OPTS} ${CATALINA_OPTS}"

conf/server.xml 수정 - Listener 추가

<Server port="8005" shutdown="SHUTDOWN">

<!-- 생략 --->

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
        rmiRegistryPortPlatform="9840" rmiServerPortPlatform="9841"/>

jdk의 jconsole.exe 실행

권한파일(jmxremote.access)과 로그인 암호파일(jmxremote.password) 생성

$ cd /usr/local/apache-tomcat-8.5.23/
$ echo -e "monitorRole readonly\ncontrolRole readwrite" > conf/jmxremote.access
$ cat conf/jmxremote.access
monitorRole readonly
controlRole readwrite
$ echo -e "monitorRole tomcat\ncontrolRole tomcat" > conf/jmxremote.password
$ cat conf/jmxremote.password
monitorRole tomcat
controlRole tomcat

setenv.sh 파일 수정

$ cd /usr/local/apache-tomcat-8.5.23/bin
$ vi setenv.sh

#!/bin/sh

JMX_OPTS=" -Dcom.sun.management.jmxremote \
           -Dcom.sun.management.jmxremote.authenticate=true \
           -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password  \
           -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access  \
           -Djava.rmi.server.hostname=192.168.0.24 \
           -Dcom.sun.management.jmxremote.ssl=false "
CATALINA_OPTS=" ${JMX_OPTS} ${CATALINA_OPTS}"

setenv.bat 파일 내용 - Windows 용

set JMX_OPTS=-Dcom.sun.management.jmxremote ^
-Dcom.sun.management.jmxremote.authenticate=true ^
-Dcom.sun.management.jmxremote.password.file=%CATALINA_HOME%/conf/jmxremote.password ^
-Dcom.sun.management.jmxremote.access.file=%CATALINA_HOME%/conf/jmxremote.access ^
-Djava.rmi.server.hostname=192.168.0.31 ^
-Dcom.sun.management.jmxremote.ssl=false

set CATALINA_OPTS=%JMX_OPTS% %CATALINA_OPTS%
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함