JDK 1.5이상부터 제공하는 Sun의 JConsole을 사용하면 VM에 대한 정보를 모니터링 할 수 있습니다. 이를 이용하여 또한 JBoss의 구동중인 VM상태를 모니터링 할 수 있습니다. 자세한 정보는 아래의 URL에서 확인하실 수 있습니다.
http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html
Technical Articles : http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

1. Local에서 구동중인 JBoss Server에 설정하기
JMX Agent를 Local의 JBoss 서버에 구동시키려면 다음의  java option을 run shell(run.conf/run.sh or run.bat)에 포함시켜 주시면 됩니다.

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-server -Xms128m -Xmx128m"
fi

# Enable the jconsole agent locally
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"

그런 다음 $JAVA_HOME/bin/jconsole을 실행시키면 다음의 화면이 나타납니다.
[jchoi@/opt/java1.5]jconsole

연결이 되면 아래의 그림처럼 VM 상황에 대한 자세한 정보를 확인할 수 있습니다.



2. Remote Server에서 구동중인 JBoss Server에 설정하기
Remote라고 해서 별다른 설정이 있는 게 아닙니다. 원격에서 실행하는 JBoss Server의 옵션에 필요한 파라미터를 전달받아 JConsole을 로컬에서 실행해서 보면 됩니다.

기본적으로는 다음의 스크립트를 추가하도록 합니다.
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-server -Xms128m -Xmx128m"
fi
# Enable the jconsole agent remotely on port 12345
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=12345"



만약 security 옵션을 사용하지 않고 모니터링하고 싶다는 다음과 같이 start shell을 꾸며주면 됩니다.
# Enable the jconsole agent remotely on port 8888
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8888"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"

위의 옵션을 준 후 jconsole을 실행시켜 remote탭을 보게 되면 연결할 수 있습니다.

위의 설정을 이용하여 추이를 지켜본 후 Memory Leak등의 여부를 그래프로 확인해볼 수 있을 겁니다.

|

놀새~'s Blog is powered by Daum & tistory