How to use jconsole to monitor remote Tomcat services

How to use jconsole to monitor remote Tomcat services

What is JConsole

JConsole was introduced in Java 5. JConsole is a built-in Java performance analyzer that can be run from the command line or in a GUI shell. You can easily use JConsole (or, its more advanced cousin VisualVM) to monitor Java application performance and trace code in Java.

1. Get the remote server address and available port number

I use my own Alibaba Cloud host, the server address is 39.107.68.142, the port number is 8696

Check whether the port number is available: netstat -tunlp|grep 8696



We can see that 6969 has been used and 8696 has not been used.

View the port where the process is started

netstat -antup |grep 32594

Check port monitoring status

lsof -i:1234

2. Modify the tomcat startup script to enable JMX

Modify the catalina.sh script file and add it at the beginning of the file

JAVA_OPTS="-Djava.rmi.server.hostname=39.107.68.142 -Dcom.sun.management.jmxremote.port=8696 -Dcom.sun.management.jmxremote.rmi.port=8696 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

in

-Dcom.sun.management.jmxremote.port=9696 //Connection port, customize it so that it does not conflict with the existing port

-Dcom.sun.management.jmxremote.rmi.port=8696 //This sentence must be added, otherwise it will not succeed

-Dcom.sun.management.jmxremote.authenticate=false //No password required to log in

-Dcom.sun.management.jmxremote.ssl=false //No security certificate is required

-Djava.rmi.server.hostname=39.107.68.142 //This ip is the external ip of your server

Location:

3. Restart the Tomcat service

When shutting down the service using shutdown.sh, an error may be reported: Error: JMX connector server communication error: service:jmx:rmi://dusk:8696

Don't worry, just kill -9 process number

View the process: ps -ef|grep tomcat

Then start the service startup.sh

Use netstat -tunlp|grep 8696 to confirm whether the port is already in the listening state

4. Open port number

If we have turned on the firewall, we need to open this port in the firewall

View the firewall status service iptables status

Open Ports:

(1) Edit the file in vi /etc/sysconfig/iptables and add the following line: -A INPUT -p tcp -m tcp --dport 8889 -j ACCEPT
(2) Execute the /etc/init.d/iptables restart command to restart the iptables service

If it is an Alibaba Cloud host, you also need to open ports in the security group:

5. Open the local jconsole to monitor the remote service

Enter in the remote process: 39.107.68.142:8696 Click Connect

Then you can check the JVM permission status

Summarize

The above is the method of using jconsole to monitor remote Tomcat services introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Solve the problem that the java maven project cannot find the jconsole-1.8.0.jar and tools-1.8.0.jar packages
  • Detailed explanation of the use of Jconsole, a JDK14 performance management tool
  • Implement thread monitoring steps based on Idea+Jconsole
  • Introduction to jconsole (picture and text)
  • How to use JConsole to observe and analyze the operation of Java programs and perform troubleshooting and tuning
  • Java JConsole remote connection configuration case detailed explanation

<<:  js to achieve the effect of light switch

>>:  How to change the root password in MySQL 5.7

Recommend

Why should css be placed in the head tag

Think about it: Why should css be placed in the h...

Summary of Vue's monitoring of keyboard events

Key Modifiers When listening for keyboard events,...

How to create a table in mysql and add field comments

Directly post code and examples #Write comments w...

Specific use of Linux gcc command

01. Command Overview The gcc command uses the C/C...

Vue implements a complete process record of a single file component

Table of contents Preface Single file components ...

CSS example code to hide the scroll bar and scroll the content

Preface When the HTML structure of a page contain...

The table merges cells and the img image to fill the entire td HTML

Source code (some classes deleted): Copy code The ...

Introducing icons by implementing custom components based on Vue

Preface In project development, there are many wa...

Solution to the MySQL error "Every derived table must have its own alias"

MySQL reports an error when executing multi-table...

Detailed installation tutorial of mysql-8.0.11-winx64.zip

Download the zip installation package: Download a...

Four ways to compare JavaScript objects

Table of contents Preface Reference Comparison Ma...