查看JVM運行參數jinfo命令

jinfo 是 JDK 自帶的命令,能夠用來查看正在運行的 java 應用程序的擴展參數,包括Java System屬性和JVM命令行參數;也能夠動態的修改正在運行的 JVM 一些參數。當系統崩潰時,jinfo能夠從core文件裏面知道崩潰的Java應用程序的配置信息

查看jvm全部參數默認值

> java -XX:+PrintFlagsInitial -version

查看jvm全部的參數

> java -XX:+PrintFlagsFinal -version

查看當前JVM運行的參數

用法:java

> jinfo -flags pid

查看系統全部的Java進程mysql

> jcmd
24386 sun.tools.jcmd.JCmd
18378 plan.war

查看plan.war進程的運行參數git

> 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:

查看具體某一個參數的值sql

> 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 =

相關文章
相關標籤/搜索