使用JMC监控tomcat
1.复制jmx账号密码模板
cp $JAVA_HOME/jre/lib/management/jmxremote.* tomcat/conf 这里复制到tomcat的conf下面 包含两个文件一个jmxremote.password和 jmxremote.access
cd $TOMCAT_HOME/tomcat/conf
mv jmxremote.password.template jmxremote.password
chmod +w jmxremote.password 添加写权限
在 password的文件下面填写 jmxuser R&D #账号 密码
在access文件下面添加
jmxuser readonly #账号 权限...具体文件里最下面有例子说明
然后给tomcat添加启动参数
-Djava.rmi.server.hostname=** -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=** -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=/usr/local/apache-tomcat-8.5.53/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/apache-tomcat-8.5.53/conf/jmxremote.access
-Djava.rmi.server.hostname 填写远程IP地址
-Dcom.sun.management.jmxremote.port 填写端口号 jmc远程连接信息要用
-Dcom.sun.management.jmxremote.password.file password的位置
-Dcom.sun.management.jmxremote.access.file access的位置
然后启动tomcat就行
后面要多开放三个端口 一个是刚才填写的-Dcom.sun.management.jmxremote.port的端口 另外两个使用
netstat -antup |grep tomcat的PID
查看
8081是我tomcat的端口 8087是刚才开放的端口 还需要两个rmi端口 12524 和 3593 这两个应该是随机开放的
不然一会jmc连接不上去
然后打开jmc
在文件->连接->创建新连接 中填写服务器信息
用户和口令填写刚才password文件里的..下一步就链接上去了