Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/u013219624/article/details/89254892
1. Introduction
to use VisualVM monitoring local JVM is simple, open it with. Then the remote monitoring of JVM how to do it, you can jstatd and JMX, but jstatd monitor does not support the CPU, the following is the configuration details
2.jstatd
# JVM所在服务器操作
touch jstatd.all.policy
vim jstatd.all.policy
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
chmod 775 jstatd.all.policy
jstatd -J-Djava.security.policy=/usr/local/java/jstatd.all.policy -J-Djava.rmi.server.hostname=182.92.234.232 -J-Djava.rmi.server.logCalls=true
# 文件绝对路径
-J-Djava.security.policy=jstatd.all.policy=
# 打开日志,如果客户端有连接过来的请求,可以监控到,便于排错
-J-Djava.rmi.server.logCalls=true
# 指明本机hostname对应的本机地址
-J-Djava.rmi.server.hostname=182.92.234.232
VisualVM then directly connect to a remote connection, jstatd monitor does not support the CPU
2.JMX
cd /usr/local/tomcat8/bin
touch setenv.sh
vim setenv.sh
#!/bin/bash
JAVA_OPTS="$JAVA_OPTS -Xms512m -Xmx512m -Djava.rmi.server.hostname=182.92.234.232 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"
chmod +x setenv.sh
cd /usr/local/tomcat8/conf
vim server.xml
<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />
cd /usr/local/tomcat8/conf
cp $JAVA_HOME/jre/lib/management/jmxremote.password.template jmxremote.password
cp $JAVA_HOME/jre/lib/management/jmxremote.access jmxremote.access
vi jmxremote.password
在这下面添加用户名密码
#monitorRole QED
#controlRole R&D
tommerRole tommer001
vi jxmremote.access
tommerRole readwrite
chmod 600 jmxremote.password
chmod 600 jmxremote.access
cd /usr/local/tomcat8/lib
wget http://central.maven.org/maven2/org/apache/tomcat/tomcat-catalina-jmx-remote/8.5.30/tomcat-catalina-jmx-remote-8.5.30.jar
Before JMX is not supported by Visual GC, but this time I found it to be operating support