问题
I'm trying to set up JVisualVm to monitor a Tomcat 6 instance (running on Ubuntu Server 10.04 LTS). I've seen other questions, but none of them directly answer my problem. I try to connect to Tomcat with JVisualvm and it comes back with a "Cannot connect" error - but there are TCP connections being made to the server; the server drops the connection after a short burst of traffic.
I have already added this to /etc/default/tomcat6 and restarted tomcat6
# This enables JMX in order to permit VisualVM to profile the JVM.
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
I started rmiregistry using default settings:
rmiregistry &
I haven't started jstatd
; installing it on the server requires the full JDK which requires X libraries. I'm not about to install X just to get one single binary.
I wonder if not running jstatd
would have something to do with it; I was of the impression that I needed neither RMI nor jstatd, as long as I could use JMX directly via the JMX port.
There is no firewall in between the server and the JVisualvm client, and the iptables host firewall is open. Using jconsole
results in the same error.
Running JVisualVM against the local Ubuntu 10.04 machine (by using its IP address and JMX port) and adding a JMX instance works fine - and I'm running neither rmiregistry
nor jstatd
- though the monitor shows RMI threads running.
Question: What must I do (either on the server or the client) in order to be able to monitor Tomcat (and other Java programs) via JMX with JVisualVM?
Thanks in advance.
回答1:
If there is no firewall, try to set java.rmi.server.hostname system property for your Tomcat. Add this to your Tomcat's JAVA_OPTS:
-Djava.rmi.server.hostname=<IP address of Ubuntu Server>
You don't need to start rmiregistry
and you don't need to run jstatd
to be able to monitor your Tomcat remotely.
回答2:
For the record: jstatd
does not require X libraries, it only depends on them via some other recommended package. You can make aptitude
or apt-get
skip installation of recommended packages and have jstatd
installed without any X11 libraries.
For aptitude
, go into options ➞ preferences ➞ Install recommended packages automatically. For apt-get
, see this question on askubuntu.
来源:https://stackoverflow.com/questions/6347261/how-do-i-monitor-tomcat6-with-jvisualvm-in-ubuntu-linux