问题
I am trying to monitor remote tomcat process with JVisualVM in Red Hat Linux. CPU sampling works fine but Memory sampling tab is disabled. It says "Memory sampling: Not available. Remote applications are not supported".
Command line parameters of process:
-Djavac.source=1.5 -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=11107
JVisualVm details:
Version:
1.6.0_24 (Build 100930); platform 100909-1140d3a55456
System:
Linux (2.6.18-53.1.14.el5) , i386 32bit
Java:
1.6.0_24; Java HotSpot(TM) Client VM (19.1-b02, mixed mode)
Is there something which I am missing. I am quite new to all this.
回答1:
Memory sampling uses Attach API, which only works for local application running under the same user as VisualVM. You can run the VisualVM on the remote machine and use remote X session to display the output on your local machine.
回答2:
You can resolved this error by
$ ssh -Y user@remotemachine
$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_135.zip
$ unzip visualvm_135.zip
$ cd visualvm_135/bin
$ ./visualvm
This instance of visualvm will be full featured, including memory and CPU sampling.
Read more about it here: http://shahriarinia.blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html
http://mshahriarinia.com/
回答3:
Following prior answers given, but had couple additional pieces to acknowledge:
- cannot sample memory remotely
- use X to run a local-to-jvm instance of VisualVM and export DISPLAY back to your workstation
there is some nasty issue with jdk_1.7.0_25 that causes at least in my case under CentOS an exception thrown trying to run jvisualvm or the downloaded VisualVM:
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.SunToolkit
use the same user account to run both your target JVM (in my case Tomcat server) and your instnace of VisualVM
From prior answer, this was useful (thank you Morteza Shahriari Nia)
$ ssh -Y user@remotemachine
$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_136.zip
$ unzip visualvm_136.zip
$ cd visualvm_136/bin
$ ./visualvm
Each time before you run "visualvm_136/bin/visualvm", get your X display back to your workstation you need to ...
- local machine: $ xhost +
- remote machine: $ export DISPLAY=your_workstation_ip:0.0
Once it starts up (and your target JVM is already running and your are same user account as per #4 above), you will see your target PID listed in the "Local" section of VisualVM.
I was able to use differing versions of jdk and still able to see memory sampler enabled - in my case the target Tomcat JVM was running jdk_1.7.0_25, whereas my VisualVM instance was earlier version jdk_1.7.0_04 (due to issue #3, had to use different version for VisualVM).
Hope that helps ...
来源:https://stackoverflow.com/questions/7417976/jvisualvm-memory-sampling-remote-applications-are-not-supported