参考:https://tomcat.apache.org/tomcat-9.0-doc/monitoring.html
https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdenl
1 不用密码访问
在TOMCAT_HOME/bin下新新建文件 seten.sh,正常这些参数应该加在catalina.sh中的启动参数中也只可以,不过有其他应用也用,为了拷贝方便,没有测试。
#!/bin/bash
CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=8099 -Dcom.sun.management.jmxremote.rmi.port=8099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=(经测试为公网ip)"
2 用密码访问
#!/bin/bash
CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=8099 -Dcom.sun.management.jmxremote.rmi.port=8099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/usr/local/tomcat-web-test/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/tomcat-web-test/conf/jmxremote.access -Djava.rmi.server.ho
stname=(经测试为公网ip)"
在 TOMCAT_HOME/conf下新建文件:jmxremote.password,此文件权限为设为只读,否则启动不了,会提示将文件设为只读
用户名 密码
在 TOMCAT_HOME/conf下新建文件: jmxremote.access,访问权限
用户名 readonly/readwrite
readonly: 用visualVM连接时只有monitor页面
用Jconsole visual连接即可,如果是带密码的,就输入设置的用户名和密码。