13.3.虚拟化工具--jinfo详解
Posted to.to
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了13.3.虚拟化工具--jinfo详解相关的知识,希望对你有一定的参考价值。
13.3.虚拟化工具–jinfo详解
实时查看和调整虚拟机的各项参数。
jinfo命令可以用来查看java进程运行的JVM参数,命令如下:
[root@admin ~]# 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
我们先用 jps 命令查到 PID ,然后可以通过 jinfo 来查看对应进程的参数信息:
[root@admin ~]# jps
43520 Test
35900 Jps
查看JVM参数:
[root@admin ~]# jinfo -flags 43520
Attaching to process ID 43520, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.45-b08
-Dfile.encoding=GBK
再如一个例子下面的Size的单位是Byte:
[admin@hadoop3 ~]$ jinfo -flags 449415
Attaching to process ID 449415, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.60-b23
Non-default VM flags: -XX:+AlwaysPreTouch -XX:CICompilerCount=15 -XX:CMSInitiatingOccupancyFraction=75 -XX:ErrorFile=null -XX:GCLogFileSize=67108864 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=null -XX:InitialHeapSize=53687091200 -XX:MaxHeapSize=53687091200 -XX:MaxNewSize=3315138560 -XX:MaxTenuringThreshold=6 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=3315138560 -XX:NumberOfGCLogFiles=32 -XX:OldPLABSize=16 -XX:OldSize=50371952640 -XX:-OmitStackTraceInFastThrow -XX:+PrintGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:ThreadStackSize=1024 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseConcMarkSweepGC -XX:+UseFastUnorderedTimeStamps -XX:+UseGCLogFileRotation -XX:+UseParNewGC
Command line: -Xms50g -Xmx50g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-9223305231604688595 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/home/admin/es/elasticsearch-6.7.1 -Des.path.conf=/home/admin/es/elasticsearch-6.7.1/config -Des.distribution.flavor=default -Des.distribution.type=tar
[admin@hadoop3 ~]$
查看系统属性:
[admin@hadoop3 ~]$ jinfo -sysprops 449415
Attaching to process ID 449415, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.60-b23
jna.platform.library.path = /usr/lib64:/lib64:/usr/lib:/lib:/usr/lib64/qt-3.3/lib:/usr/lib64/mysql:/usr/lib64//bind9-export
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /usr/java/jdk1.8.0_60/jre/lib/amd64
java.vm.version = 25.60-b23
es.path.home = /home/admin/es/elasticsearch-6.7.1
log4j.shutdownHookEnabled = false
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
jna.loaded = true
sun.os.patch.level = unknown
user.country = CN
sun.java.launcher = SUN_STANDARD
es.networkaddress.cache.negative.ttl = 10
jna.nosys = true
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /home/admin/es/elasticsearch-6.7.1
java.runtime.version = 1.8.0_60-b27
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.endorsed.dirs = /usr/java/jdk1.8.0_60/jre/lib/endorsed
os.arch = amd64
java.io.tmpdir = /tmp/elasticsearch-9223305231604688595
line.separator =
es.networkaddress.cache.ttl = 60
es.logs.node_name = hadoop3
java.vm.specification.vendor = Oracle Corporation
os.name = Linux
io.netty.noKeySetOptimization = true
sun.jnu.encoding = UTF-8
jnidispatch.path = /tmp/elasticsearch-9223305231604688595/jna-92668751/jna8806494672259821954.tmp
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
sun.nio.ch.bugLevel =
es.logs.cluster_name = elasticsearch
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-862.el7.x86_64
user.home = /home/admin
user.timezone = Asia/Shanghai
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
es.distribution.type = tar
io.netty.recycler.maxCapacityPerThread = 0
user.name = admin
es.logs.base_path = /home/admin/es/eslogs
java.class.path = /home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-x-content-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-cli-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-core-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-secure-sm-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-core-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-analyzers-common-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-backward-codecs-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-grouping-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-highlighter-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-join-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-memory-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-misc-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-queries-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-queryparser-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-sandbox-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-spatial-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-spatial-extras-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-spatial3d-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/lucene-suggest-7.7.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/hppc-0.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/joda-time-2.10.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/t-digest-3.2.jar:/home/admin/es/elasticsearch-6.7.1/lib/HdrHistogram-2.1.9.jar:/home/admin/es/elasticsearch-6.7.1/lib/spatial4j-0.7.jar:/home/admin/es/elasticsearch-6.7.1/lib/jts-core-1.15.0.jar:/home/admin/es/elasticsearch-6.7.1/lib/log4j-api-2.11.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/log4j-core-2.11.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/log4j-1.2-api-2.11.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/jna-4.5.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/snakeyaml-1.17.jar:/home/admin/es/elasticsearch-6.7.1/lib/jackson-core-2.8.11.jar:/home/admin/es/elasticsearch-6.7.1/lib/jackson-dataformat-smile-2.8.11.jar:/home/admin/es/elasticsearch-6.7.1/lib/jackson-dataformat-yaml-2.8.11.jar:/home/admin/es/elasticsearch-6.7.1/lib/jackson-dataformat-cbor-2.8.11.jar:/home/admin/es/elasticsearch-6.7.1/lib/jopt-simple-5.0.2.jar:/home/admin/es/elasticsearch-6.7.1/lib/plugin-classloader-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/java-version-checker-6.7.1.jar:/home/admin/es/elasticsearch-6.7.1/lib/elasticsearch-launchers-6.7.1.jar
es.path.conf = /home/admin/es/elasticsearch-6.7.1/config
java.vm.specification.version = 1.8
java.home = /usr/java/jdk1.8.0_60/jre
sun.java.command = org.elasticsearch.bootstrap.Elasticsearch -d
sun.arch.data.model = 64
io.netty.noUnsafe = true
user.language = zh
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
java.version = 1.8.0_60
java.ext.dirs = /usr/java/jdk1.8.0_60/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /usr/java/jdk1.8.0_60/jre/lib/resources.jar:/usr/java/jdk1.8.0_60/jre/lib/rt.jar:/usr/java/jdk1.8.0_60/jre/lib/sunrsasign.jar:/usr/java/jdk1.8.0_60/jre/lib/jsse.jar:/usr/java/jdk1.8.0_60/jre/lib/jce.jar:/usr/java/jdk1.8.0_60/jre/lib/charsets.jar:/usr/java/jdk1.8.0_60/jre/lib/jfr.jar:/usr/java/jdk1.8.0_60/jre/classes
java.awt.headless = true
java.vendor = Oracle Corporation
file.separator = /
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
es.distribution.flavor = default
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
log4j2.disable.jmx = true
sun.cpu.isalist =
虚拟机的参数可以通过这个命令查看:
java -XX:+PrintFlagsFinal -version | grep manageable
除了通过启动脚本可以设置参数,PrintGC 默认是打开的,因此我们只需要打开 PrintGCDetails 参数。
jinfo -flag +PrintGC 43520
jinfo -flag +PrintGCDetails 43520
关闭 GC 日志的话同理:
jinfo -flag -PrintGC 43520
jinfo -flag -PrintGCDetails 43520
查看是否开启GC日志的打印:
jinfo -flag PrintGC 43520
jinfo -flag PrintGCDetails 43520
[root@admin ~]# jinfo -flag PrintGC 43520
-XX:-PrintGC
[root@admin ~]# jinfo -flag PrintGCDetails 43520
-XX:-PrintGCDetails
常用JVM参数:
-Xms:初始堆大小,默认为物理内存的1/64(<1GB);默认(MinHeapFreeRatio参数可以调整)空余堆内存小于40%时,JVM就会增大堆直到-Xmx的最大限制
-Xmx:最大堆大小,默认(MaxHeapFreeRatio参数可以调整)空余堆内存大于70%时,JVM会减少堆直到 -Xms的最小限制
-Xmn:新生代的内存空间大小,注意:此处的大小是(eden+ 2 survivor space)。与jmap -heap中显示的New gen是不同的。整个堆大小=新生代大小 + 老生代大小 + 永久代大小。在保证堆大小不变的情况下,增大新生代后,将会减小老生代大小。此值对系统性能影响较大,Sun官方推荐配置为整个堆的3/8。
-XX:SurvivorRatio:新生代中Eden区域与Survivor区域的容量比值,默认值为8。两个Survivor区与一个Eden区的比值为2:8,一个Survivor区占整个年轻代的1/10。
-Xss:每个线程的堆栈大小。JDK5.0以后每个线程堆栈大小为1M,以前每个线程堆栈大小为256K。应根据应用的线程所需内存大小进行适当调整。在相同物理内存下,减小这个值能生成更多的线程。但是操作系统对一个进程内的线程数还是有限制的,不能无限生成,经验值在3000~5000左右。一般小的应用, 如果栈不是很深, 应该是128k够用的,大的应用建议使用256k。这个选项对性能影响比较大,需要严格的测试。和threadstacksize选项解释很类似,官方文档似乎没有解释,在论坛中有这样一句话:"-Xss is translated in a VM flag named ThreadStackSize”一般设置这个值就可以了。
-XX:PermSize:设置永久代(perm gen)初始值。默认值为物理内存的1/64。
-XX:MaxPermSize:设置持久代最大值。物理内存的1/4。
: 后面的 + 或 - 表示使用或不使用。
以上是关于13.3.虚拟化工具--jinfo详解的主要内容,如果未能解决你的问题,请参考以下文章
jvm性能监控故障处理命令行工具详解(jpsjstatjinfojmapjhatjstack)(宝藏博文)
深入理解Java虚拟机——Java配置信息工具(jinfo)