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

How to get datetime data in mysql, followed by .0

The data type of MySQL is datetime. The data stor...

Two implementation solutions for vuex data persistence

Table of contents Business requirements: Solution...

JavaScript Regular Expressions Explained

Table of contents 1. Regular expression creation ...

Pitfall notes of vuex and pinia in vue3

Table of contents introduce Installation and Usag...

Vue routing to implement login interception

Table of contents 1. Overview 2. Routing Navigati...

Nginx Service Quick Start Tutorial

Table of contents 1. Introduction to Nginx 1. Wha...

Docker installs ClickHouse and initializes data testing

Clickhouse Introduction ClickHouse is a column-or...

Examples of using Docker and Docker-Compose

Docker is an open source container engine that he...

MySQL aggregate function sorting

Table of contents MySQL result sorting - Aggregat...

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

How to query data from multiple unrelated tables and paging in Mysql

Mysql multiple unrelated tables query data and pa...