【问题标题】:How to use jmap remotelly without SSL?如何在没有 SSL 的情况下远程使用 jmap?
【发布时间】:2015-06-09 17:06:21
【问题描述】:

我已经配置了我的 linux 远程机器(使用 JRE 1.7)来执行具有 jmx 必要属性的 java 应用程序:

java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=5005 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar myapplication.jar

现在在我的 windows 本地机器上(我有 JDK 1.7)我想使用工具 jmap,例如打印直方图:

jmap -histo 10.218.72.227:5005

但它因以下错误而失败:

Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Attaching to remote server 10.218.72.227:5005, please wait...
Error attaching to remote server: java.rmi.NotBoundException: Not bound: "SARemoteDebugger" (only bound name is "jmxrmi")

奇怪的是,我可以使用 jconsole 成功连接,但首先它会提示我一条消息以不安全的方式重试连接(不使用 SSL):

因此,它似乎应该是 jmap 的某种标志才能工作,你知道如何克服这个问题吗?

【问题讨论】:

    标签: java ssl java-7 jmx remote-debugging


    【解决方案1】:

    遵循jsadebugd - Serviceability Agent Debug Daemon 的手册页 您需要先将其附加到您的进程才能远程使用jmap

    以下步骤显示了它的工作原理。

    所有 Java 进程(本地和远程)使用的 Java 版本。

    java版本“1.7.0_80”
    Java(TM) SE 运行时环境(内部版本 1.7.0_80-b15)
    Java HotSpot(TM) 服务器虚拟机(build 24.80-b11,混合模式)

    在远程主机上执行

    1. 开始你的申请
      java -jar myapplication.jar
    2. 启动rmiregistry
      rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sajdi.jar &
    3. 使用jps(例如12345)获取应用程序的PID
    4. 将调试恶魔附加到您的应用程序
      jsadebugd 12345 42

    在本地主机上执行

    1. 执行jmap
      jmap -heap 42@10.218.72.227

    在本地主机上输出

    Attaching to remote server 42@10.218.72.227, please wait...
    Debugger attached successfully.
    Server compiler detected.
    JVM version is 24.80-b11
    Iterating over heap. This may take a while...
    Object Histogram:
    
    num       #instances    #bytes  Class description
    --------------------------------------------------------------------------
    1:      5575    527488  * ConstMethodKlass
    2:      5575    493168  * MethodKlass
    ...
    

    附加说明:手册页声明This utility is unsupported and may or may not be available in future versions of the JDK

    也许在远程机器上运行 jmap(例如通过 ssh)会是更好的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-10
      • 2014-01-16
      • 1970-01-01
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 2017-03-01
      相关资源
      最近更新 更多