乐趣区

关于jvm:查看JVM运行参数jinfo命令

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 = 

退出移动版