标题1.在java应用客户端新建三个文件,位置自行选定,路径在配置文件改
jmxremote.access
jmxremote.password
management.properties
标题2.修改配置文件
vim jmxremote.access
monitorRole readonly
controlRole readwrite
create javax.management.monitor.,javax.management.timer.
unregister
vim jmxremote.password #monitorRole为用户,QED为密码
monitorRole QED
修改文件权限
chmod 600 jmxremote.password
vim management.properties
#enable remote management of MBean
com.sun.management.jmxremote=true
java.rmi.server.hostname=10.0.0.120 #java应用所在机器IP
com.sun.management.jmxremote.port=1099
com.sun.management.jmxremote.rmi.port=1100
com.sun.management.jmxremote.local.only=false
#enable authentication
com.sun.management.jmxremote.authenticate=true #使用账户密码授权登录
com.sun.management.jmxremote.password.file=/文件路径/jmxremote.password
com.sun.management.jmxremote.access.file=/文件路径/jmxremote.access
#disable SSL authentication
com.sun.management.jmxremote.ssl=false
标题3.非阻塞式启动java 应用 # management.properties会调用另外两个文件
nohup /java环境路径/java -jar -Xmx256m -Dspring.profiles.active=dev -Dfile.encoding=UTF-8 -Dcom.sun.management.config.file=/文件路径/management.properties /jar文件路径/servicename.jar &
#复制到虚拟机格式就好了
标题4.望鹰配置插件
参数示列
-c [{“urlPath”:“service:jmx:rmi:///jndi/rmi://10.0.0.120:1099/jmxrmi”,“username”:“monitorRole”,“password”:“QED”,“endpoint”:“10.0.0.120”}]
后台测试
/jmx_monitor_start.sh -c ‘[{“urlPath”:“service:jmx:rmi:///jndi/rmi://10.0.0.120:1099/jmxrmi”,“username”:“monitorRole”,“password”:“QED”,“endpoint”:“10.0.0.120”}]’
标题5.用Windows java 环境自带 jmx 连接工具验证
打开本机 java 环境安装目录,bin 下面的 jvisualvm.exe 工具
文件选择添加 jmx 连接
service:jmx:rmi:///jndi/rmi://10.0.0.120:1099/jmxrmi
monitorRole QED
左边打开连接
选择监视
说明该 jmx 连接是有效的