My Tomcat 7 process, which I run on a server on Amazon EC2, has settings such as these in CATALINA_OPTS
which should allow me to connect for JMX monitoring remotely:
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
However, connecting remotely does not work with either jconsole or jvisualvm. It just times out.
I've triple-checked that the EC2 security group allows access to the JMX remote port from my IP (and only from my IP).
Are there any settings missing?
Specify the java.rmi.server.hostname option too, so that it points to the public DNS name of your EC2 server:
-Djava.rmi.server.hostname=your.public.dns
That was sufficient to get it working for me, but for more tips, try this blog post:
JMX Monitoring on Amazon EC2
Here is more complete explanation of how to do it without messing with the group security (aka firewall):
Server side:
add following listener to server.xml:
add following settings in tomcat/bin/setenv.sh:
Restart tomcat
Client side:
start ssh tunnel with:
Start JConsole and enter the following remote service URL:
You have JConsole connected over SSH to your tomcat running on AWS.
As posted on: http://www.cod.ro/2012/08/monitoring-tomcat-7-on-rhel-aws-using.html
If you're having trouble setting the correct hostname for
java.rmi.server.hostname
try the following:This is convenient to use in an Elastic Beanstalk environment where instances will come and go.
I also tried using the JmxRemoteLifecycleListener and it didn't work for me.
This is what it worked for me:
I choose 1005 as JMX port and my
setenve.sh
is like:Redirect using SSH the JMX port and the RMI
Run visualvm using the following URI:
If you need more information have a look to this post: http://ignaciosuay.com/how-to-connect-a-java-profiler-like-visualvm-or-jconsole-to-a-remote-tomcat-running-on-amazon-ec2/