1、修改文件
# tomcat 的 bin 目录下
vim setenv.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.23.131 -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
chmod a+x setenv.sh
# 启动 tomcat
./bin/startup.sh
# 查看工具
jdk1.8.0_151/bin/jvisualvm.exe
2、使用工具检测
# 下载工具
cmdline-jmxclient
# 运行命令
java -jar cmdline-jmxclient-0.10.3.jar - 127.0.0.1:9999 java.lang:type=Memory HeapMemoryUsage
3、docker 方式
version: "3"
services:
tomcat:
image: daocloud.io/library/tomcat:8.5.15-jre8
ports:
- "8080:8080"
- "9999:9999"
container_name: tomcat
volumes:
- "/usr/local/service/tomcat/tomcat8080:/usr/local/tomcat/webapps"
environment:
- CATALINA_OPTS=-Djava.rmi.server.hostname=10.10.1.127 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.rmi.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
privileged: true