Tomcat
获取Tomcat的进程号
tomcatPid=`pgrep -u tomcat java`
如果遇到tomcat用户包含其他Java进程的,你可以使用如下命令获取,
tomcatPid=`jps" | grep Bootstrap | awk -F ' ' '{print $1}`
获取Tomcat的堆栈信息
sudo -u tomcat /usr/local/jdk-15.0.2/bin/jstack -l "$tomcatPid" > /data/jstack.log
获取JVM heap dump(堆栈快照)信息
sudo -u tomcat /usr/local/jdk-15.0.2/bin/jmap -dump:live,format=b,file=/data/heap-dump.hprof "$tomcatPid"
另外,以下命令等价,
sudo -u tomcat /usr/local/jdk-15.0.2/bin/jcmd "$tomcatPid" GC.heap_dump /data/heap-dump.hprof
另外,如果需要启动Java时候就自动输出“JVM heap dump”可按如下格式设置,
java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=
参阅文档
================
官方资料
————-
https://docs.oracle.com/en/java/javase/15/docs/api/index.html
https://docs.oracle.com/en/java/javase/15/docs/api/jdk.jcmd/module-summary.html
https://docs.oracle.com/en/java/javase/15/docs/specs/man/jcmd.html
https://docs.oracle.com/en/java/javase/15/docs/specs/man/jstack.html
https://docs.oracle.com/en/java/javase/15/docs/specs/man/jmap.html
没有评论