一. 使用jmx让远程工具连接java进程
开启jmx:
- 无需验证的配置:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=1234
-Dcom.sun.management.jmxremote.ssl=false - 将-Dcom.sun.management.jmxremote.authenticate=false 去掉就是需要验证信息
即:登录名和密码:验证用户的配置文件在$java_homejre/lib/management/jmxremote.password
默认有一个$java_home/jre/lib/management/jmxremote.password.template
修改下即可。
jmxremote.password.template默认是只读权限。
并更改为可写的权限 chmod a+w jmxremote.password
修改后把jmxremote.password的读权限取消 a-r 。否则会提示:Error: Password file read access must be restricted:
management/jmxremote.access配置下权限。
连接时指定ip:端口和jmx连接即可。
远程的线程dump可以dump查看,堆的dump是需要从远程拉到本地来查看。