虚拟机监控和分析工具
来源:互联网 发布:素描大师软件下载 编辑:程序博客网 时间:2024/06/04 19:10
背景:
给一个系统定位问题的时候,知识、经验是关键基础,数据是依据,工具是运用知识处理数据的手段。数据包括:运行日志,异常堆栈、GC日志、线程快照(threaddump/javacore文件)、堆转储快照(humpdump/hprof文件)。定位问题的时候,恰当使用虚拟机监控和分析工具可以起到事半功倍的效果。
1、JDK的命令行工具
JDK的bin目录下java.exejavac.exejps:JVM Process Status Tool,显示指定系统内所以HotSpot虚拟机进程jstat: JVM Statistics Monitoring Tool,用于收集HotSpot虚拟机各方面的运行数据jinfo:Configuration Info for Java,显示虚拟机配置信息jmap:Memory for Java,生成虚拟机的内存转储快照(heapdump文件)jhat:JVM Heap Dump Browser,用于分析heapdump文件,它会建立一个HTTP/HTML服务器,让用户可以在浏览器上查看分析结果jstack:Stack Trace for Java,显示虚拟机的线程快照
2、JDK监控和分析工具详解
jps概述:
类似Linux的ps命令,可以列出正在运行的虚拟机进程、显示虚拟机执行主类(Main Class,main()函数所在的类)名称以及这些进程的本地虚拟机唯一ID(Local Virtual Machine Identifier,LVMID)
jps命令格式:
jps[options][hostid]
jps执行样列:
C:\Users\Administrator>jps -l73043872 sun.tools.jps.Jps
jps工具主要选项
===============================
jstat:虚拟机统计信息监视工具
监视虚拟机各种运行状态信息的命令行工具,显示本地或远程虚拟机中的类装载、内存、垃圾收集、JIT编译等运行数据。它是运行期定位虚拟机性能问题的首先工具。
jstat命令格式
jstat[option vmid[interval [s|ms][count]]]参数:VMID与LVMID的区别,如果是本地虚拟机进程,VMID与LVMID是一致的,如果是远程虚拟机,那么VMID的格式为:[protocol:][//]lvmid[@hostname[:port]/servername]interval:查询间隔,可省略count:查询次数,可省略
jstat执行样列
样列1
jstat -gc 2764 250 20每隔250毫秒查询一次进程2764垃圾收集状况,一共查询20次
样列2
C:\Users\Administrator>jstat -gcutil 7304 S0 S1 E O P YGC YGCT FGC FGCT GCT 0.00 0.00 6.18 43.31 99.76 126 2.227 117 37.535 39.762
解释:
新生代Eden区(E,表示Eden)使用了6.18%的空间,两个Survivor(S0,S1表示Survivor0、Survivor1)里面都是空的,老年代(O,表示Old)和永久代(P,表示Permanent)则分别使用了43.31%和99.76%的空间。程序运行以来共发生Minor GC(YGC,表示Young GC)共126次,总共耗时2.227秒,发生Full GC(FGC,表示Full GC)117次,Full GC总耗时(FGCT,表示Full GC Time)为37.535秒,所以GC总耗时(GCT,表示GC Time)为39.762秒。
C:\Users\Administrator>jinfoUsage: jinfo [option] <pid> (to connect to running process) jinfo [option] <executable <core> (to connect to a core file) jinfo [option] [server_id@]<remote server IP or hostname> (to connect to remote debug server)where <option> is one of: -flag <name> to print the value of the named VM flag -flag [+|-]<name> to enable or disable the named VM flag -flag <name>=<value> to set the named VM flag to the given value -flags to print VM flags -sysprops to print Java system properties <no option> to print both of the above -h | -help to print this help messageC:\Users\Administrator>jstatinvalid argument countUsage: jstat -help|-options jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]Definitions: <option> An option reported by the -options option <vmid> Virtual Machine Identifier. A vmid takes the following form: <lvmid>[@<hostname>[:<port>]] Where <lvmid> is the local vm identifier for the target Java virtual machine, typically a process id; <hostname> is the name of the host running the target Java virtual machine; and <port> is the port number for the rmiregistry on the target host. See the jvmstat documentation for a more complete description of the Virtual Machine Identifier. <lines> Number of samples between header lines. <interval> Sampling interval. The following forms are allowed: <n>["ms"|"s"] Where <n> is an integer and the suffix specifies the units as milliseconds("ms") or seconds("s"). The default units are "ms". <count> Number of samples to take before terminating. -J<flag> Pass <flag> directly to the runtime system.
jstat工具主要选项
==================================
jinfo:Java配置信息工具
实时查看和调整虚拟机各项参数。
使用jps命令的-v参数可以查看虚拟机启动时显示指定的参数列表,
但如果想知道未被显示指定的参数的系统默认值,可以使用jinfo的-flag选项进行查询。
此外,jinfo的-sysprops选项把虚拟机进程的System.getProperties()的内容打印出来。
jinfo命令格式:
jinfo[option]pid
执行样列:
C:\Users\Administrator>jinfo -flag CMSIntiatingOccupancyFraction 1444查询CMSIntiatingOccupancyFraction参数值
C:\Users\Administrator>jinfoUsage: jinfo [option] <pid> (to connect to running process) jinfo [option] <executable <core> (to connect to a core file) jinfo [option] [server_id@]<remote server IP or hostname> (to connect to remote debug server)where <option> is one of: -flag <name> to print the value of the named VM flag -flag [+|-]<name> to enable or disable the named VM flag -flag <name>=<value> to set the named VM flag to the given value -flags to print VM flags -sysprops to print Java system properties <no option> to print both of the above -h | -help to print this help message
==================================
jmap:Java内存映像工具
生成堆转储快照(一般称为humpdump文件或dump文件)
查询finalize执行队列、Java堆和永久代的详细信息,如空间使用率、当前使用的是哪种收集器等。
jmap命令格式
jmap[option]vmid
jmap工具主要选项option
使用样列:
C:\Users\Administrator>jmap -dump: format=b,file=eclipse.bin 6844
C:\Users\Administrator> jmapUsage: jmap [option] <pid> (to connect to running process) jmap [option] <executable <core> (to connect to a core file) jmap [option] [server_id@]<remote server IP or hostname> (to connect to remote debug server)where <option> is one of: <none> to print same info as Solaris pmap -heap to print java heap summary -histo[:live] to print histogram of java object heap; if the "live" suboption is specified, only count live objects -permstat to print permanent generation statistics -finalizerinfo to print information on objects awaiting finalization -dump:<dump-options> to dump java heap in hprof binary format dump-options: live dump only live objects; if not specified, all objects in the heap are dumped. format=b binary format file=<file> dump heap to <file> Example: jmap -dump:live,format=b,file=heap.bin <pid> -F force. Use with -dump:<dump-options> <pid> or -histo to force a heap dump or histogram when <pid> does not respond. The "live" suboption is not supported in this mode. -h | -help to print this help message -J<flag> to pass <flag> directly to the runtime system
- 虚拟机监控和分析工具
- 虚拟机性能监控和故障处理工具
- Java性能分析及问题解决(一)虚拟机性能监控和故障处理工具
- 虚拟机性能监控工具
- 虚拟机 监控工具
- JDK下虚拟机性能监控以及故障分析工具
- 性能监控和分析工具--nmon
- mysql监控和性能分析工具
- 性能监控和分析工具--nmon
- mysql监控和性能分析工具
- 性能监控和分析工具--nmon
- Jmeter工具的运用和分析监控
- 硬盘监控和分析工具:Smartctl
- 3.虚拟机性能监控和故障处理工具
- Java JVM 读书笔记 - 虚拟机性能监控和故障处理工具
- Java深入 - Java虚拟机 常用监控和故障处理工具
- JVM虚拟机:JDK监控和故障处理工具
- Java虚拟机深入学习之四: Java虚拟机的性能监控和故障处理工具
- DAG优化
- 关于ScrollView嵌套ListView和GridView最常见的两种问题
- 快速排序(随机版)
- WebService 四种发布方式总结
- java常识
- 虚拟机监控和分析工具
- 第三方之QQ登录
- Robot Framework 安装Tips (windows版本)
- iview使用Menu组件动态生成时active-name不起作用
- redis集群搭建
- git中fetch和pull区别
- ie6兼容性问题详解
- RxJS 核心概念之Subject
- Tomcat9源代码分析(一)-源码切入点