java JVisualVM 内存采样:不支持远程应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7417976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JVisualVM Memory Sampling : Remote applications are not supported
提问by RandomQuestion
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".
我正在尝试在 Red Hat Linux 中使用 JVisualVM 监视远程 tomcat 进程。CPU 采样工作正常,但内存采样选项卡被禁用。它说“内存采样:不可用。不支持远程应用程序”。
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:
JVisualVm 详细信息:
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.
有什么我想念的。我对这一切都很陌生。
采纳答案by Tomas Hurka
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.
内存采样使用Attach API,它仅适用于与 VisualVM 在同一用户下运行的本地应用程序。您可以在远程机器上运行 VisualVM 并使用远程 X 会话在本地机器上显示输出。
回答by Morteza Shahriari Nia
You can resolved this error by
您可以通过以下方式解决此错误
$ ssh -Y user@remotemachine
$ ssh -Y user@remotemachine
$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_135.zip
$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_135.zip
$ unzip visualvm_135.zip
$ 解压缩visualvm_135.zip
$ cd visualvm_135/bin
$ cd visualvm_135/bin
$ ./visualvm
$ ./visualvm
This instance of visualvm will be full featured, including memory and CPU sampling.
这个visualvm 实例将是全功能的,包括内存和CPU 采样。
Read more about it here: http://shahriarinia.blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html
在此处阅读更多相关信息:http: //shahriarinia.blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html
回答by Yekoof
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
- 无法远程采样内存
- 使用 X 运行 VisualVM 的本地到 jvm 实例并将 DISPLAY 导出回您的工作站
jdk_1.7.0_25 存在一些令人讨厌的问题,至少在我的情况下,在 CentOS 下会导致尝试运行 jvisualvm 或下载的 VisualVM 时抛出异常:
java.lang.NoClassDefFoundError:无法初始化类 sun.awt.SunToolkit
使用相同的用户帐户来运行你的目标 JVM(在我的例子中是 Tomcat 服务器)和你的 VisualVM 实例
From prior answer, this was useful (thank you Morteza Shahriari Nia)
从先前的回答来看,这很有用(谢谢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 ...
每次运行“visualvm_136/bin/visualvm”之前,将您的 X 显示器放回您的工作站,您需要...
- local machine: $ xhost +
- remote machine: $ export DISPLAY=your_workstation_ip:0.0
- 本地机器:$ xhost +
- 远程机器:$ 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.
一旦它启动(并且您的目标 JVM 已经在运行并且您的用户帐户与上面的 #4 相同),您将看到您的目标 PID 列在 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).
我能够使用不同版本的 jdk 并且仍然能够看到启用了内存采样器 - 在我的情况下,目标 Tomcat JVM 正在运行 jdk_1.7.0_25,而我的 VisualVM 实例是早期版本 jdk_1.7.0_04(由于问题 #3,必须为 VisualVM 使用不同的版本)。
Hope that helps ...
希望有帮助...