Jconsole Tomcat memory monitoring settings

Source: Internet
Author: User
Tags jconsole

Jconsole is a good JVM viewing tool that comes with JDK. It is free of charge, and the memory status is refreshed quickly and garbage collection is also fast. To monitor the memory leakage of a Web application to be launched, You need to monitor the JVM memory of Tomcat. Jconsole is based on JMX for communication and information sending and Retrieval. Therefore, you need to configure Tomcat so that jconsole can monitor tomcat.

1. In Windows, it is usually our development environment

In Windows, Tomcat parameters are usually set in our development environment. The first response is to modify Catalina. BAT and other files. My personal opinion is that these startup files should not be changed as much as possible, which is not very good. Fortunately, Java Development is basically based on Eclipse or myeclipse. Therefore, you only need to set the startup parameters of the Tomcat server in the eclipse or myeclipse server configuration.

For example, myeclipse8.5, Windows-> preferences à myeclipse à servers à tomcat6. In its JDK optional Java VM arguments settings, enter the following content:

-Xmx256m-xms128m

-Djava. RMI. server. hostname = 192.168.10.101

-DCOM. Sun. Management. JMX remote. Port = 8061

-DCOM. Sun. Management. jmxremote. SSL = false

-DCOM. Sun. Management. jmxremote. Authenticate = false

After setting, start Tomcat in myeclipse. We can start jconsole connection 192.168.0.1: 8061 for Tomcat JVM memory monitoring.

 

2. in Linux

Currently, Tomcat applications on most production machines are deployed on Linux or Unix machines, and few are deployed on Windows. This document uses Linux as an example.

Based on my previous principles, do not modify startup files such as Catalina. Sh. Manually create a start file with the following content:

Java_home =/usr/Java/jdk1.6.0 _ 06/

Export at_home =/usr/Java/Apache-Tomcat-6.0.16

Path = $ java_home/bin: tomcat_home/bin: $ path

Classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar

Export java_home

Export path

Export classpath

Catalina_opts = "-xmx3072m-xms3072m-djava. RMI. server. hostname = 192.168.1.101-DCOM. sun. management. jmxremote. port = 8061-DCOM. sun. management. jmxremote. authenticate = true-DCOM. sun. management. jmxremote. SSL = false-DCOM. sun. management. jmxremote. password. file = $ java_home/JRE/lib/management/jmxremote. password"

Export catalina_opts

/Usr/Java/Apache-Tomcat-6.0.16/bin/startup. Sh

Store the start file in the Tomcat bin directory. We only need the following command to start Tomcat:

At-F/usr/Java/Apache-Tomcat-6.0.16/bin/start now

DCOM. sun. management. jmxremote. authenticate = true-DCOM. sun. management. jmxremote. password. file = $ java_home/JRE/lib/management/jmxremote. password, jconsole to connect to 192.168.1.101: 8061 requires user name and password verification to ensure security.

In fact, two files are used: The jmxremote. Access file and the jmxremote. Password File. The former sets the user, the latter sets the user and the corresponding password. This file is available in $ java_home/JRE/lib/management. You only need to modify the user and password.

Note that the access permission of jmxremote. Password must be set to the owner readable. Otherwise, the error similar to jmxremote. Password resticted will be reported if Tomcat fails to start.

 

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.