一、修改要訪問的遠程主機(Linux)相關文件,本文檔只介紹了java-jvisualvm的JMX方式:
1.打開$CATALINA_HOME/bin/startup.sh, 找到倒數第二行(也就是exec "$PRGDIR"/"$EXECUTABLE" start "$@"一行上邊)加上如下內容:
export CATALINA_OPTS="$CATALINA_OPTS-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.*.* -Dcom.sun.management.jmxremote.port=7003 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/opt/apache-tomcat-6.0.18/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/opt/apache-tomcat-6.0.18/conf/jmxremote.access"
2.備注:
-Dcom.sun.management.jmxremote 啟用JMX遠程監控
-Djava.rmi.server.hostname=192.168.*.* 連接的服務器地址
-Dcom.sun.management.jmxremote.port=7003 jmx連接端口
-Dcom.sun.management.jmxremote.ssl=false 是否ssl加密
-Dcom.sun.management.jmxremote.authenticate=true 遠程連接需要密碼認證(如為false后面的可省略);
-Dcom.sun.management.jmxremote.password.file=/opt/apache-tomcat-6.0.18/conf/jmxremote.password 指定連接的用戶名和密碼配置文件
-Dcom.sun.management.jmxremote.access.file=/opt/apache-tomcat-6.0.18/conf/jmxremote.access 指定連接的用戶所擁有權限的配置文件
3.其中jmxremote.password文件:
monitorRole roor123
controlRole root123
4.jmxremote.access文件:
monitorRole readonly
controlRole readwrite
5.重啟Tomcat服務。
二、在本地(Windows)創建jvisualvm--JMX連接
1.打開本地安裝JDK_HOME/bin目錄:C:\Java\jdk1.7.0_80\bin
2.雙擊:jvisualvm.exe

3.右鍵添加遠程主機:

4.新建JMX連接

5.查看:

