How to enable remote JVM monitoring using jre's built in JConsole

This guide will help you setup a remote jvm monitoring tool using jconsole.

The setup:
1.) Ubuntu 12.04
2.) Glassfish 3.1.2.2
3.) jdk1.6.0_32

Steps:
1.) In your glassfish's default domain1 domain.xml file, /glassfish_home/glassfish/domains/domain1/config/domain.xml, add the following lines in the jvm section:
<jvm-options>-Djava.net.preferIPv4Stack=true</jvm-options>
<jvm-options>-Dcom.sun.aas.jconsole.server.cbport=18687</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.ssl=false</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.authenticate=false</jvm-options>
<jmx-connector address="0.0.0.0" auth-realm-name="admin-realm" name="system" port="18686" protocol="rmi_jrmp" security-enabled="false"/>

//you can set the fully qualified domain name if you have, otherwise we will connect using ip
<jvm-options>-Djava.rmi.server.hostname=mydomain.com
2.) Rename /usr/lib/jvm/jdk1.6.0_32/jre/lib/management/jmxremote.password.template->/usr/lib/jvm/jdk1.6.0_32/jre/lib/management/jmxremote.password

3.) Uncomment monitorRole and controlRole users

4.) Change the owner of /usr/lib/jvm/jdk1.6.0_32/jre/lib/management/jmxremote.password, the same as the owner of glassfish folder:
sudo chown owner:group /usr/lib/jvm/jdk1.6.0_32/jre/lib/management/jmxremote.password
sudo chmod 600 /usr/lib/jvm/jdk1.6.0_32/jre/lib/management/jmxremote.password

5.) Restart glassfish and connect from a remote machine using JConsole, enter the IP and port 8686. Example: 192.168.0.106:8686
How to enable remote JVM monitoring using jre's built in JConsole How to enable remote JVM monitoring using jre's built in JConsole Reviewed by Edward Legaspi on Saturday, August 25, 2012 Rating: 5

No comments:

Powered by Blogger.