1, JMX function
1.1 Introduction
JMX (Java Management Extensions, the Java Management Extensions) is an application program, devices, systems and other implants framework management functions. JMX across a range of heterogeneous operating system platform, system architecture and network transport protocols , flexible development seamlessly integrated system, network and service management applications.
The so-called JMX, is an acronym for Java Management Extensions (Java Management Extensions) is a framework for implant management functions for the application. Users can use these agents and service management to achieve in any Java application.
JMX architecture diagram:
Three-tier structure
1, the base layer: mainly Mbean, managed java bean They are divided into the following four Mbean
2, adaptation layer: MbeanServer, provide registration and management of resources 3, the access layer: providing remote access to an inlet |
The most common scenario is JMX basic information and monitor the operation of Java programs, a Java program can open any JMX, and then use JConsole or Visual VM preview.
Adding JMX 1.2 features
1, wrapper program to add JMX functionality.
Add the following configuration wrapper.conf configuration file:
local.jmx.port=39900 wrapper.java.additional.2=-Djava.rmi.server.hostname=192.168.1.75 wrapper.java.additional.3=-Dcom.sun.management.jmxremote.port=39900 wrapper.java.additional.4=-Dcom.sun.management.jmxremote.ssl=false wrapper.java.additional.5=-Dcom.sun.management.jmxremote.authenticate=false |
2, the general procedure to add JMX java function.
Specify the following instruction after the program command java
-Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=1000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false |
3, tomcat JMX add functionality.
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=ip -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" |
2, Jconsole, jvisualvm tools
2.1 jconsole tool
1, the remote connection process
2, the connection is successful may be observed overview, memory, threads, classes, the VM summary, the MBean
3, you can view a different area of memory usage
2.2 jvisualvm tools
1, the remote connection process
2, you can see an overview of successful login, monitoring, thread, sampler.
3, monitors: CPU, memory, class, thread
4, memory mirroring can be done by decimator
Check the resulting file on a remote server:
3, file parsing heap
3.1, use the command parsing jhat
jhat -J-mx10240m heapdump-1563861495449.hprof
The following message appears, indicating that the image file is read successfully
3.2, page display
Input UI using the following address: http://192.168.1.75:7000/
You can view the page by:
(1) shows all classes included in the stack
(2) from the root set references to an object can be
(3) shows the number of instances of all classes of platforms including
Distribution Table (4) Examples of the stack
(5) perform object query
4, JVM tuning monitoring tools
jps、jstack、jmap、jhat、jstat、hprof
jmap这个命令执行,JVM会将整个heap的信息dump写入到一个文件,heap如果比较大的话,就会导致这个过程比较耗时,并且执行的过程中为了保证dump的信息是可靠的,所以会暂停应用, 线上系统慎用。