如何从HashiCorp Nomad运行的Java应用程序中获取堆转储?

时间:2017-06-08 11:03:38

标签: java jvm heap dump nomad

我有由HashiCorp Nomad运行的java应用程序。在进程状态输出中,我有root运行的nomad执行程序进程和nobody运行的java应用程序进程。

当我尝试执行命令时: jmap -dump:format=b,file=filename.bin <app_pid>

我收到了消息:

Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding

当我尝试执行命令时:jmap -dump:format=b,file=filename.bin <app_pid> -F

我接下来追踪:

Attaching to core -F from executable 5584, please wait... Error attaching to core file: cannot open binary file sun.jvm.hotspot.debugger.DebuggerException: cannot open binary file at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:286) at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:673) at sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:611) at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:337) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304) at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:156) at sun.jvm.hotspot.tools.Tool.start(Tool.java:191) at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118) at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.tools.jmap.JMap.runTool(JMap.java:201) at sun.tools.jmap.JMap.main(JMap.java:130)

1 个答案:

答案 0 :(得分:1)

没有-F的

jmap应该由与目标Java进程相同的用户运行(在您的情况下为nobody)。

jmap -F应由root运行,-F参数应位于<app_pid>之前:

jmap -dump:format=b,file=filename.bin -F <app_pid>

请参阅this answers中的详细信息。