java 无法在 VisualVM 中查看 Visual GC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16233275/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 22:19:00  来源:igfitidea点击:

Unable to view Visual GC in VisualVM

javalinuxprofilervisualvm

提问by ajay

I am using Java VisualVM on my local windows machine to monitor my remote server(Linux). I am able to get all stats in Bisual VM except "Visual GC". It shows "Not Supported for this JVM". I have googled it and find that it might be because jstatd is not running and connected. So executed "jstatd -J-Djava.security.policy=/tmp/tools.policy". It shows a ip "175.41.139.225". I can't understand why it is trying to connect to this ip. It is not the ip of my remote machine nor of my local machine.

我在本地 Windows 机器上使用 Java VisualVM 来监控我的远程服务器(Linux)。我能够在 Bisual VM 中获得除“ Visual GC”之外的所有统计数据。它显示“不支持此 JVM”。我用谷歌搜索了一下,发现可能是因为 jstatd 没有运行和连接。所以执行了“ jstatd -J-Djava.security.policy=/tmp/tools.policy”。它显示了一个 ip“ 175.41.139.225”。我不明白为什么它试图连接到这个 ip。它不是我的远程机器的 IP,也不是我的本地机器的 IP。

[root@shipping_pt mail]# jstatd -J-Djava.security.policy=/tmp/tools.policy
Could not contact registry
Connection refused to host: 175.41.139.225; nested exception is:
        java.net.ConnectException: Connection refused
java.rmi.ConnectException: Connection refused to host: 175.41.139.225; nested exception is:
        java.net.ConnectException: Connection refused
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340)
        at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
        at java.rmi.Naming.rebind(Naming.java:177)
        at sun.tools.jstatd.Jstatd.bind(Jstatd.java:57)
        at sun.tools.jstatd.Jstatd.bind(Jstatd.java:66)
        at sun.tools.jstatd.Jstatd.main(Jstatd.java:143)
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
        at java.net.Socket.connect(Socket.java:546)
        at java.net.Socket.connect(Socket.java:495)
        at java.net.Socket.<init>(Socket.java:392)
        at java.net.Socket.<init>(Socket.java:206)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
        ... 8 more

回答by Hemant Thorat

On remote server,

在远程服务器上,

vim /tmp/tools.policy

Add,

添加,

grant codebase "file:${java.home}/../lib/tools.jar" {
   permission java.security.AllPermission;
};

And start jstatsd

并启动 jstatsd

jstatd -J-Djava.security.policy=/tmp/tools.policy -J-Djava.rmi.server.hostname=<public_ip>

and you ready are with Visual GC inside VisualVM on local machine.

你准备好在本地机器上的 VisualVM 中使用 Visual GC。

回答by Tomas Hurka

You are right that you need to run jstatd to be able to use VisualGC plugin, because VisualGC uses jvmstat API. It looks like you are running jstatdas root. Is you monitored application running as 'root'? How does /tmp/tools.policy file looks like? Try to run jstatd with the following args:

你是对的,你需要运行 jstatd 才能使用 VisualGC 插件,因为 VisualGC 使用jvmstat API。看起来您正在jstatd以 root 身份运行。您是否以“root”身份运行受监控的应用程序?/tmp/tools.policy 文件是什么样的?尝试使用以下参数运行 jstatd:

jstatd -J-Djava.rmi.server.hostname=<IP address of shipping_pt machine> -J-Djava.security.policy=/tmp/tools.policy

回答by Peter Lawrey

VsiualVM is very version dependant. If you can connect but some functionality is not available, I would make sure you are running the exactly the same version of the Java.

VsiualVM 非常依赖于版本。如果您可以连接但某些功能不可用,我会确保您运行的是完全相同版本的 Java。

If you can't connect you need to change the permissions of your JVM. Note: you can only see your processes by default.

如果无法连接,则需要更改 JVM 的权限。注意:默认情况下您只能看到您的进程。