简体   繁体   English

在未成功运行的 JDK-8 java 进程上使用 JDK-11 运行 jcmd

[英]Running jcmd using JDK-11 on JDK-8 java process not running successfully

I am trying to monitor native memory of tomcat using jcmd but getting following exception: Command: jcmd 14533<pid of tomcat> VM.native_memory summary我正在尝试使用 jcmd 监控 tomcat 的本机内存,但出现以下异常:命令: jcmd 14533<pid of tomcat> VM.native_memory summary

I have installed 2 jdk's jdk-11 AND jdk-8 .我已经安装了 2 个jdk's jdk-11jdk-8

Tomcat is running by jdk-8 and jcmd used jdk-11 then i got following exception: Tomcat 由jdk-8运行,jcmd 使用jdk-11然后我得到以下异常:

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/31752/root/tmp/.java_pid31752: target process 31752 doesn't respond within 10500ms or HotSpot VM not loaded
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:100)
    at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
    at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
    at jdk.jcmd/sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:114)
    at jdk.jcmd/sun.tools.jcmd.JCmd.main(JCmd.java:98)

I attched -XX:+StartAttachListener with java process but it didn't work.我用 java 进程-XX:+StartAttachListener-XX:+StartAttachListener但它没有用。

It can be a user permission issue: jmap has to be run with the same user as the java process.这可能是用户权限问题:jmap 必须与 java 进程使用相同的用户运行。 eg if the owner is usera and this is running in a docker contained execute jmap as user usera例如,如果所有者是usera并且它在包含的 docker 中运行,则以用户usera身份执行 jmap

docker exec --user usera -it container_id jmap -dump:format=b,file=/home/usera/memorydump.bin 1

If you are running tomcat as a service on linux check following config in unit file ie tomcat.service如果您在 linux 上将 tomcat 作为服务运行,请检查以下单元文件中的配置,即 tomcat.service

  1. PrivateTmp=yes, should be removed. PrivateTmp=yes,应该删除。 As PrivateTmp=yes create private /tmp folder which is not accessible by tool由于 PrivateTmp=yes 创建工具无法访问的私有 /tmp 文件夹
  2. If you have ProtectSystem=strict, add ReadWritePaths=/tmp/如果你有 ProtectSystem=strict,添加 ReadWritePaths=/tmp/

Go through man page for systemd unit file config查看 systemd 单元文件配置的手册页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM