查看运行中的 Tomcat 的 JVM 的配置信息

一、Tomcat 与 JVM 的关系

Tomcat 是一个 Java 程序, 它需要在一个 JVM 中运行。当启动 Tomcat 时,即启动一个 Java 程序时,必然会有一个 JVM 进程被创建,作为 Tomcat (Java 程序)的运行环境。

二、查看运行中的 Tomcat 的 JVM 的配置信息

1. 查看 JVM 的 pid
  • 命令
         jps
  • 例如
 [root@localhost bin]# jps
3256 Jps
3149 Bootstrap
[root@localhost bin]# ps -aux|grep 3149
  • 可以看到有两个 JVM 进程

  • 3256 是刚刚运行的 jps 命令的 JVM。jps 是一个 java 工具,本质上也是一个 java 程序,也需要在 JVM 中运行

  • 3149 是 Bootstrap 的 JVM。信息不够详细,下面通过 ps 命令来做进一步的分析

    1. 查看 pid 对应的 JVM 进程的详细信息
  • 命令

         ps -aux | grep pid
  • 例如
[root@localhost bin]# ps -aux|grep 3149
root       3149  1.3  8.3 2292020 83144 pts/1   Sl   15:26   0:04 /home/lqing/jdk1.8.0_121/bin/java -Djava.util.logging.config.file=/home/lqing/apache-tomcat-8.5.27/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /home/lqing/apache-tomcat-8.5.27/bin/bootstrap.jar:/home/lqing/apache-tomcat-8.5.27/bin/tomcat-juli.jar -Dcatalina.base=/home/lqing/apache-tomcat-8.5.27 -Dcatalina.home=/home/lqing/apache-tomcat-8.5.27 -Djava.io.tmpdir=/home/lqing/apache-tomcat-8.5.27/temp org.apache.catalina.startup.Bootstrap start
root       3275  0.0  0.0 112660   664 pts/1    R+   15:32   0:00 grep --color=auto 3149
[root@localhost bin]#
  • pid 对应的 command 为:

/home/lqing/jdk1.8.0_121/bin/java -Djava.util.logging.config.file=/home/lqing/apache-tomcat-8.5.27/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /home/lqing/apache-tomcat-8.5.27/bin/bootstrap.jar:/home/lqing/apache-tomcat-8.5.27/bin/tomcat-juli.jar -Dcatalina.base=/home/lqing/apache-tomcat-8.5.27 -Dcatalina.home=/home/lqing/apache-tomcat-8.5.27 -Djava.io.tmpdir=/home/lqing/apache-tomcat-8.5.27/temp org.apache.catalina.startup.Bootstrap start
-  通过 command 的内容可以确定,这个进程就是 Tomcat 的 JVM 进程


3. 通过 JDK 提供的工具 jinfo 查看 JVM 的配置信息
  • 命令
         jinfo pid
  • 例如
[root@localhost bin]# jinfo 3149
Attaching to process ID 3149, please wait
Debugger attached successfully.
Server compiler detected.
JVM version is 25.121-b13
Java System Properties:
java.runtime.name = Java(TM) SE Runtime Environment
java.vm.version = 25.121-b13
sun.boot.library.path = /home/lqing/jdk1.8.0_121/jre/lib/amd64
java.protocol.handler.pkgs = org.apache.catalina.webresources
shared.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
java.util.logging.config.file = /home/lqing/apache-tomcat-8.5.27/conf/logging.properties
tomcat.util.buf.StringCache.byte.enabled = true
sun.os.patch.level = unknown
sun.java.launcher = SUN_STANDARD
user.country = CN
tomcat.util.scan.StandardJarScanFilter.jarsToScan = log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar
user.dir = /home/lqing/apache-tomcat-8.5.27/bin
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.8.0_121-b13
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = /home/lqing/jdk1.8.0_121/jre/lib/endorsed
line.separator =
java.io.tmpdir = /home/lqing/apache-tomcat-8.5.27/temp
java.vm.specification.vendor = Oracle Corporation
java.util.logging.manager = org.apache.juli.ClassLoaderLogManager
java.naming.factory.url.pkgs = org.apache.naming
os.name = Linux
sun.jnu.encoding = UTF-8
ignore.endorsed.dirs =
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.class.version = 52.0
java.specification.name = Java Platform API Specification
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 3.10.0-693.17.1.el7.x86_64
java.util.concurrent.ForkJoinPool.common.threadFactory = org.apache.catalina.startup.SafeForkJoinWorkerThreadFactory
user.home = /root
user.timezone = Asia/Shanghai
catalina.useNaming = true
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
tomcat.util.scan.StandardJarScanFilter.jarsToSkip = bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,jaspic-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar,taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,objenesis-*.jar,ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar
catalina.home = /home/lqing/apache-tomcat-8.5.27
user.name = root
java.class.path = /home/lqing/apache-tomcat-8.5.27/bin/bootstrap.jar:/home/lqing/apache-tomcat-8.5.27/bin/tomcat-juli.jar
java.naming.factory.initial = org.apache.naming.java.javaURLContextFactory
package.definition = sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat.
java.vm.specification.version = 1.8
sun.arch.data.model = 64
sun.java.command = org.apache.catalina.startup.Bootstrap start
java.home = /home/lqing/jdk1.8.0_121/jre
user.language = zh
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
java.version = 1.8.0_121
java.ext.dirs = /home/lqing/jdk1.8.0_121/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /home/lqing/jdk1.8.0_121/jre/lib/resources.jar:/home/lqing/jdk1.8.0_121/jre/lib/rt.jar:/home/lqing/jdk1.8.0_121/jre/lib/sunrsasign.jar:/home/lqing/jdk1.8.0_121/jre/lib/jsse.jar:/home/lqing/jdk1.8.0_121/jre/lib/jce.jar:/home/lqing/jdk1.8.0_121/jre/lib/charsets.jar:/home/lqing/jdk1.8.0_121/jre/lib/jfr.jar:/home/lqing/jdk1.8.0_121/jre/classes
server.loader =
java.vendor = Oracle Corporation
catalina.base = /home/lqing/apache-tomcat-8.5.27
jdk.tls.ephemeralDHKeySize = 2048
file.separator = /
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
common.loader = "${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar"
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
package.access = sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat.
sun.cpu.isalist =
VM Flags:
Non-default VM flags: -XX:CICompilerCount=2 -XX:InitialHeapSize=16777216 -XX:MaxHeapSize=255852544 -XX:MaxNewSize=85262336 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=5570560 -XX:OldSize=11206656 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps
Command line:  -Djava.util.logging.config.file=/home/lqing/apache-tomcat-8.5.27/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -Dcatalina.base=/home/lqing/apache-tomcat-8.5.27 -Dcatalina.home=/home/lqing/apache-tomcat-8.5.27 -Djava.io.tmpdir=/home/lqing/apache-tomcat-8.5.27/temp
  • 前一部分是 JVM 的 -sysprops 信息
  • 后一部分是 JVM 的 -flags 信息
  • 我们最常查看的 JVM 配置信息,可以就是内存相关配置,这时,我们只要查看 -flags 信息即可:
    • 命令
jinfo -flags  pid
- 例如
[root[@localhost](https://my.oschina.net/u/570656) bin]# jinfo -flags  3149
Attaching to process ID 3149, please wait
Debugger attached successfully.
Server compiler detected.
JVM version is 25.121-b13
Non-default VM flags: -XX:CICompilerCount=2 -XX:InitialHeapSize=16777216 -XX:MaxHeapSize=255852544 -XX:MaxNewSize=85262336 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=5570560 -XX:OldSize=11206656 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps
Command line:  -Djava.util.logging.config.file=/home/lqing/apache-tomcat-8.5.27/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -Dcatalina.base=/home/lqing/apache-tomcat-8.5.27 -Dcatalina.home=/home/lqing/apache-tomcat-8.5.27 -Djava.io.tmpdir=/home/lqing/apache-tomcat-8.5.27/temp
[root[@localhost](https://my.oschina.net/u/570656) bin]#

三、感言

如有错误,欢迎大家批评指正。

转载于:https://my.oschina.net/AndyWannaSing/blog/1621649

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值