What JVISUALVM can do: monitor memory leaks, track garbage collection, perform memory, CPU analysis, threading analysis ...
JVISUALVM has been integrated in more than jdk1.6 versions (not JRE). Requires a minimum jdk1.6 version for its own operation, but can monitor Java programs running on versions above jdk1.4
Jdk1.6update45 (Jdk1.6update45 comes with the JVISUALVM) to do the instructions, of course, you can also download separate JVISUALVM, after the normal installation of the JDK, to the JDK bin directory, run Jvisualvm.exe can
Online Some people say JVISUALVM to NTFS hard disk format support is not good (all say bad, also not in the end where bad), anyway, I use is quite normal, no matter how to first write down the way to solve
Create Jvisualvm.exe shortcuts, right-click Shortcuts, select Properties, append "-xx:+perfbypassfilesystemcheck" to the "target" column
The program will automatically monitor the running Java program (under the local tag, the Java program on the remote server needs to be configured separately), if it is downloaded JVISUALVM, after decompression, run the bin directory Jvisualvm.exe can be
The first VISUALVM under the Local tab is the JVISUALVM to monitor itself, and can see that the resources consumed are still scarce, and the second is native to eclipse
The monitoring items are divided into overview,monitor,threads and a sampler altogether.
1.Overview (JVM startup parameters, System parameters)
You can see the startup parameters of Eclipse
(with these startup parameters, you can tell if the program has a memory overflow)
2.Monitor
Top left: CPU utilization, GC status monitoring
Top right: Heap utilization, utilization of the permanent memory area
Bottom Left: class monitoring
Bottom right: Thread monitoring
Detailed operational status of the PERFORMGC:GC
Heapdump: The detailed state of the heap (you can see a summary of the heap, all the classes inside, and the ability to point to a specific class to see the state of the Class)
3.Threads
The ability to display the name and running state of a thread is essential when debugging multiple threads, and you can point to a thread to see the details of the thread running
Tomcat on the monitor server
Added in Tomcat configuration file catalina.sh:
Java_opts= "-dcom.sun.management.jmxremote.port=9998-dcom.sun.management.jmxremote.ssl=false- dcom.sun.management.jmxremote.authenticate=false-djava.rmi.server.hostname=192.168.58.164 "
Parameter description:
A JMX-initiated proxy port is specified, which is the port VISUALVM to connect to (port 9998 cannot be used by another program Netstat-an|gerp 9998) dcom.sun.management.jmxremote.port= 9998 Specifies whether JMX enable Ssldcom.sun.management.jmxremote.authenticate=false Specifies whether JMX enables authentication (requires username, Password Authentication) dcom.sun.management.jmxremote.authenticate=false Specifies the server host name djava.rmi.server.hostname=192.168.58.164
Fill in the host name:
Right-click to create a JMX connection:
Fill in the upper slogan:
Configuration complete:
Monitoring Java programs on the server
Much more hassle than monitoring Tomcat, pre-booting the JSTATD service (${java_home}/bin directory)
JSTATD is a server program that monitors the JVM's resource usage from creation to destruction and provides a remote monitoring interface (remote method invocation), which is a daemon program (background process), To ensure that remote monitoring software is connected to the local, you need to jstatd always keep running.
The jstatd operation needs to specify the security policy through-j-djava.security.policy=***, so we need to set up a file on the server that specifies the security policy jstatd.all.policy (I put the ${java_home}/ Bin directory), the file contents are as follows:
Then use this policy file to start the JSTATD service
[Email protected] bin]$ Pwd/home/123/123/jdk1.5.0_15/bin[[email protected] bin]$./jstatd-j-djava.security.policy=. /jstatd.all.policy &
Because the monitoring process requires the JSTATD service to run continuously, so add the & If you need a log, you can use it:
./jstatd-j-djava.security.policy=./jstatd.all.policy-j-djava.rmi.server.logcalls=true
Next, you can configure the Java programs that are running on the server in JVISUALVM, and the procedures for configuring the monitor Tomcat server in JVISUALVM are the same.
It is important to note that sometimes JVISUALVM will report an error when configuring a remote monitoring Java program.
Click to view error Details:
Connection refused to host:127.0.0.1 preliminary judgment is related to host name
[Email protected] bin]# hostname-i127.0.0.1
[Email protected] bin]# hostname 192.168.58.168
After modifying the restart JSTATD service (many people on the web said to modify the host's/etc/hosts file, but I myself test to modify the/etc/hosts file is not effective, you must modify the host name)
Fill in the host name:
Here is the option to add a JSTATD connection:
Select the default configuration directly (using port 1099 by default):
When you click OK, all Java programs on 168 are automatically listed:
Ps:
JVISUALVM also can install plug-ins, the specific steps for tool-plugin->aviable plugin, recommend a very useful plug-in VISUALGC
After the plugin is installed, a new monitoring entry will be added to the visual GC to see the usage of the virtual machine memory areas
Java JVISUALVM Brief description