简体   繁体   English

Tomcat线程转储

[英]Tomcat thread dump

Is there away to take a thread dump from Tomcat. 有没有从Tomcat采取线程转储 I want to monitor the running threads on Tomcat at a certain time. 我想在某个时间监视Tomcat上正在运行的线程。

Note: I was doing that on Web logic but i don't know how it cab be done on Tomcat. 注意:我在Web逻辑上这样做,但我不知道如何在Tomcat上完成它。

如果你使用Linux,你可以发送一个kill -3 [你的tomcat的pid],它将转储catalina.out中的所有当前线程。

There is a simple way to monitor tomcat threads and do a dump. 有一种监视tomcat线程并执行转储的简单方法。 Start tomcat with the folowing java options : 使用以下java选项启动tomcat:

-Dcom.sun.management.jmxremote.port=<some free port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

After the tomcat is restarted you can simply start jconsole (part of jdk) or visualvm and create a new jmx connection to the port you have chosen above. 重新启动tomcat后,您只需启动jconsole(jdk的一部分)或visualvm,并创建一个新的jmx连接到上面选择的端口。
In both tools you also have an option to take a dump ;) 在这两个工具中,您还可以选择转储;)

!!!But do that only in closed/secured environment - since there is no authentication set.!!! !!!但是只在封闭/安全的环境中这样做 - 因为没有认证设置。!!!

add java melody to your server https://code.google.com/p/javamelody/ 将java旋律添加到您的服务器https://code.google.com/p/javamelody/

it give you a lot of info including threads in runtime 它为您提供了很多信息,包括运行时的线程

The following steps should help you get the current Java threads running and analyze them: 以下步骤应该可以帮助您运行当前的Java线程并对其进行分析:

  1. Download IBM JCA which is a nice thread dump analyzer from IBM Thread & Dump Monitor Analyzer IBM Thread&Dump Monitor Analyzer下载IBM JCA,这是一个很好的线程转储分析器
  2. Execute the following to get the Tomcat threads dump: root@localhost:~# sudo -u $TOMCAT_USER $JAVA_HOME/bin/jstack -J-d64 -l $(ps aux | grep '[c]atalina' | awk '{print $2}') > ~/threads.log 执行以下命令获取Tomcat线程转储: root@localhost:~# sudo -u $TOMCAT_USER $JAVA_HOME/bin/jstack -J-d64 -l $(ps aux | grep '[c]atalina' | awk '{print $2}') > ~/threads.log
  3. Open the threads dump with IBM Thread & Dump Monitor Analyzer 使用IBM Thread&Dump Monitor Analyzer打开线程转储

Note: Replace $JAVA_HOME with your path to your current JDK, $TOMCAT_USER with the user running Tomcat; 注意:$JAVA_HOME替换$JAVA_HOME您当前JDK的路径, $TOMCAT_USER与运行Tomcat的用户; if you pass the wrong user or even using root you will get an error like this: 如果您传递错误的用户甚至使用root,您将收到如下错误:

3047: well-known file is not secure

Please try netbeans profiler to profile any web applications. 请尝试使用netbeans profiler来分析任何Web应用程序。

https://profiler.netbeans.org/ https://profiler.netbeans.org/

http://wiki.netbeans.org/FaqProfilerAttachRemoteServer http://wiki.netbeans.org/FaqProfilerAttachRemoteServer

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

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