JINFO介绍
“JINFO 命令工具可以从一个正在运行的java应用进程或者崩溃记录中获取配置属性,打印用于启动JVM的系统属性或命令行属性”
JINFO基本命令
1.概览
可以通过jinfo -help 查看jinfo支持的命令。如下:
/usr/local/java8/bin/jinfo -help
Usage:
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
2.详细介绍
命令 | 说明 | 命令执行结果 |
jinfo pid | 以name-value的形式打印jvm启动参数和系统参数 | /usr/local/java8/bin/jinfo 155543 Java System Properties: java.runtime.name = Java(TM) SE Runtime Environment java.vm.version = 25.45-b02 sun.boot.library.path = /usr/local/jdk1.8.0_45/jre/lib/amd64 java.protocol.handler.pkgs = org.springframework.boot.loader java.vendor.url = http://java.oracle.com/ java.vm.vendor = Oracle Corporation path.separator = : file.encoding.pkg = sun.io java.vm.name = Java HotSpot(TM) 64-Bit Server VM sun.os.patch.level = unknown sun.java.launcher = SUN_STANDARD user.country = US
VM Flags: Non-default VM flags: -XX:CICompilerCount=2 -XX:+CMSClassUnloadingEnabled
Command line: -Xloggc:/var/
|
jinfo <-flag name> pid | 打印指定参数的值 | /usr/local/java8/bin/jinfo -flag CICompilerCount 155543 -XX:CICompilerCount=2 |
jinfo <-flag [+/-]name> pid | 设置boolean型属性生效/失效 | /usr/local/java8/bin/jinfo -flag -HeapDumpOnOutOfMemoryError 155543 /usr/local/java8/bin/jinfo -flag HeapDumpOnOutOfMemoryError 155543 -XX:-HeapDumpOnOutOfMemoryError |
jinfo <-flags> pid | 打印JVM参数信息 | /usr/local/java8/bin/jinfo -flags 155543 Attaching to process ID 155543, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.45-b02 Non-default VM flags: -XX:CICompilerCount=2 |
jinfo <-sysprops> pid | 打印系统属性 | /usr/local/java8/bin/jinfo -sysprops 155543 Attaching to process ID 155543, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.45-b02 java.runtime.name = Java(TM) SE Runtime Environment java.vm.version = 25.45-b02 sun.boot.library.path = /usr/local/jdk1.8.0_45/jre/lib/amd64 java.protocol.handler.pkgs = org.springframework.boot.loader java.vendor.url = http://java.oracle.com/ java.vm.vendor = Oracle Corporation |
备注
在JDK8中介绍了JMC,JFR,JCMD等工具用来诊断jvm和java应用问题,与jinfo相比jcmd有更强的诊断能力和更小的性能开销。
JCMD的使用参考:https://blog.csdn.net/fresh_student_1/article/details/104750024
参考资料
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr013.html