How to remotely monitor and optimize the memory and CPU of Tomcat and Java programs using JVISUALVM

Source: Internet
Author: User

How to remotely monitor and optimize the memory and CPU of Tomcat and Java programs using VISUALVM


JVISUALVM is a masterpiece after the Java JConsole, a tool that integrates many tools for analyzing and optimizing Java programs.

We can use it to optimize the memory footprint of Java programs, to find memory leaks, to analyze the CPU usage of Java programs, to optimize JVM configuration based on the data acquired by JVISUALVM, and so on. The overall is quite good ~ ~ ~

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/83/A0/wKiom1d4wBPj5-X8AACbdoyqUhw909.jpg "title=" 111. JPG "alt=" wkiom1d4wbpj5-x8aacbdoyquhw909.jpg "/>

JVISUALVM is located in the Java_home/bin directory. Run directly to open. Open the following interface as follows:

Since JVISUALVM itself is a Java program, it is also acquired by the tool, can be opened to see what it looks like!


If the Java program is local, we can easily monitor these programs. If the program is remote, it will be a little bit of trouble.
We need to configure JMX or JSTATD on the remote server to use JVISUALVM

1. Start RMI Service through JSTATD

To configure Java secure Access, save the following code as a file Jstatd.all.policy, and put it in Java_home/bin, with the following contents:

Grant CodeBase "file:${java.home}/. /lib/tools.jar "{

Permission java.security.AllPermission;

};

Execute command jstatd-j-djava.security.policy=jstatd.all.policy-j-djava.rmi.server.hostname=192.168.1.8 & (192.168.1.8 The IP address of your server,& means running as a daemon thread)

JSTATD Command Explanation: http://hzl7652.iteye.com/blog/1183182

Open JVISUALVM, right-click Remort, select "Add remort Host ..." and enter your remote IP in the popup box, such as 192.168.1.8. The connection was successful.

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/83/A0/wKiom1d4xPXRK2PFAACdjyyZyDA299.jpg "style=" float: none; "title=" 2222.jpg "alt=" Wkiom1d4xpxrk2pfaacdjyyzyda299.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/83/9F/wKioL1d4xPXjffk8AAFlW7zpTOA966.jpg "style=" float: none; "title=" 3333.jpg "alt=" Wkiol1d4xpxjffk8aaflw7zptoa966.jpg "/>

Due to the limited JSTATD monitoring capabilities, you may need to use JMX remote monitoring.

2, remote monitoring through JMX.

Enter the remote server Tomcat configuration to include the following configuration in the boot file:

 start   )        "$JSVC"   $JSVC _opts        -java-home  "$JAVA _home"        -user $ tomcat_user       -pidfile  "$CATALINA _pid"         -wait  "$SERVICE _start_wait_time"        -outfile   "$CATALINA _out"        -errfile  "&1"         -classpath  "$CLASSPATH"         "$LOGGING _config"   $JAVA _opts  $CATALINA _opts       -djava.endorsed.dirs= "$JAVA _ Endorsed_dirs "       -dcatalina.base=" $CATALINA _base "        -dcatalina.home= "$CATALINA _home"        - Djava.io.tmpdir= "$CATALINA _tmp"    &nBsp;         -dprogram.name= "$PROGNAME"         -djava.rmi.server.hostname= "Your host IP address"        - Dcom.sun.management.jmxremote.port= "8534"        - Dcom.sun.management.jmxremote.authenticate= "false"        - Dcom.sun.management.jmxremote.ssl= "false"         $CATALINA _main       exit $?    ;;

which

-djava.rmi.server.hostname= "Your host IP Address"-dcom.sun.management.jmxremote.port= "8534"-dcom.sun.management.jmxremot E.authenticate= "false"-dcom.sun.management.jmxremote.ssl= "false" \

is a new addition.

where-dcom.sun.management.jmxremote.port= "8543" specifies a JMX-initiated proxy port, which is the port to which the Visual VM is connected

where-dcom.sun.management.jmxremote.ssl= "false" Specifies whether JMX is enabled for SSL

where-dcom.sun.management.jmxremote.authenticate= "false" Specifies whether JMX enables authentication (requires username, password Authentication)


Then restart the remote Tomcat program and add the JMX connection on the JVISUALVM.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/9F/wKioL1d4x_WyJ9S3AAFzdmmdTLk849.jpg "title=" Qq20160703155903.jpg "alt=" Wkiol1d4x_wyj9s3aafzdmmdtlk849.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/83/A0/wKiom1d4x6SgzZP5AAF6eXLnvlg017.jpg "title=" 55555. JPG "alt=" wkiom1d4x6sgzzp5aaf6exlnvlg017.jpg "/>

If you need to use JMX authentication: Refer to one of my other articles: http://hiandroidstudio.blog.51cto.com/5902332/1795340

This article is from the "hiandroid Studio" blog, be sure to keep this source http://hiandroidstudio.blog.51cto.com/5902332/1795310

How to remotely monitor and optimize the memory and CPU of Tomcat and Java programs using JVISUALVM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.