jinfo 是 JDK 自带的命令,可以用来查看正在运行的 java 应用程序的扩展参数,包括Java System属性和JVM命令行参数;也可以动态的修改正在运行的 JVM 一些参数。当系统崩溃时,jinfo可以从core文件里面知道崩溃的Java应用程序的配置信息
查看jvm所有参数默认值
> java -XX:+PrintFlagsInitial -version
查看jvm所有的参数
> java -XX:+PrintFlagsFinal -version
查看当前JVM
运行的参数
用法:
> jinfo -flags pid
查看系统所有的Java进程
> jcmd
24386 sun.tools.jcmd.JCmd
18378 plan.war
查看plan.war
进程的运行参数
> jinfo -flags 18378
Attaching to process ID 18378, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12
Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=262144000 -XX:MaxHeapSize=4164943872 -XX:MaxNewSize=1388314624 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=87031808 -XX:OldSize=175112192 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
Command line:
查看具体某一个参数的值
> jinfo -flag InitialHeapSize 18378
开启/关闭某个JVM参数
使用 jinfo 可以在不重启虚拟机的情况下,可以动态的修改 jvm 的参数。尤其在线上的环境特别有用。
描述:开启或者关闭对应名称的参数,主要是针对 boolean 值的参数设置的
> jinfo -flag [+|-]name pid
> jinfo -flag PrintGC 18378
-XX:-PrintGC
> jinfo -flag +PrintGC 18378
> jinfo -flag PrintGC 18378
-XX:+PrintGC
> jinfo -flag -PrintGC 18378
> jinfo -flag PrintGC 18378
-XX:-PrintGC
修改某个JVM
进程的值
jinfo虽然可以在java程序运行时动态地修改虚拟机参数,但并不是所有的参数都支持动态修改
> jinfo -flag name=value pid
输出当前JVM
进程所有的系统属性
> jinfo -sysprops pid
> jinfo -sysprops 18378
Attaching to process ID 18378, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12
java.runtime.name = Java(TM) SE Runtime Environment
jna.platform.library.path = /usr/lib64:/lib64:/usr/lib:/lib:/usr/lib64/mysql
java.vm.version = 25.261-b12
sun.boot.library.path = /usr/local/jdk1.8/jre/lib/amd64
mail.smtp.sendpartial = true
java.vendor.url = http://java.oracle.com/
java.vm.vendor = Oracle Corporation
path.separator = :
guice.disable.misplaced.annotation.check = true
file.encoding.pkg = sun.io
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
jna.loaded = true
sun.os.patch.level = unknown
sun.java.launcher = SUN_STANDARD
user.country = US
user.dir = /root
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.8.0_261-b12
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = /usr/local/jdk1.8/jre/lib/endorsed
line.separator =
java.io.tmpdir = /tmp
java.vm.specification.vendor = Oracle Corporation
os.name = Linux
mail.smtps.sendpartial = true
sun.jnu.encoding = UTF-8
jnidispatch.path = /root/.cache/JNA/temp/jna4559128793649671554.tmp
jetty.git.hash = de97d26f7bd222a0e16831e353d702a7a422f711
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 3.10.0-957.el7.x86_64
user.home = /root
user.timezone = Asia/Shanghai
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
user.name = root
java.class.path = jenkins.war
java.vm.specification.version = 1.8
sun.arch.data.model = 64
sun.java.command = jenkins.war
java.home = /usr/local/jdk1.8/jre
user.language = en
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
java.version = 1.8.0_261
java.ext.dirs = /usr/local/jdk1.8/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /usr/local/jdk1.8/jre/lib/resources.jar:/usr/local/jdk1.8/jre/lib/rt.jar:/usr/local/jdk1.8/jre/lib/sunrsasign.jar:/usr/local/jdk1.8/jre/lib/jsse.jar:/usr/local/jdk1.8/jre/lib/jce.jar:/usr/local/jdk1.8/jre/lib/charsets.jar:/usr/local/jdk1.8/jre/lib/jfr.jar:/usr/local/jdk1.8/jre/classes
java.awt.headless = true
java.vendor = Oracle Corporation
file.separator = /
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.font.fontmanager = sun.awt.X11FontManager
sun.cpu.endian = little
executable-war = /root/jenkins.war
sun.cpu.isalist =