使用Java VisualVM遠程監控Tomcat


    1. Tomcat環境變量指定的好習慣html

    安裝完Tomcat以後,配置CATALINA_HOME和CATALINA_BASE環境變量,若是須要指定環境變量或者JVM參數值,根據catalina.sh文件中的註釋說明單獨在setenv.sh或者setenv.bat文件中指定,這樣catalina.sh在執行的時候會自動讀取。java

   

   2. 配置啓用Tomcat JMX Remotetomcat

      Java Visual VM遠程監控Tomcat,配置參見:bash


JAVA_OPTS="
	-Djava.rmi.server.hostname=192.168.88.29
	-Dcom.sun.management.jmxremote
	-Dcom.sun.management.jmxremote.port=8089
	-Dcom.sun.management.jmxremote.ssl=false
	-Dcom.sun.management.jmxremote.authenticate=true
	-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password
	-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"

 

    若是authenticate=false的時候不須要配置paasword.file和access.file.不然須要在access.file中指定用戶名和讀寫權限,格式如:
服務器

   

monitorRole readonly
controlRole readwrite


    password.file中指定用戶名和密碼,格式如:ide


monitorRole tomcat
controlRole tomcat

    

    文檔中有個小提示:The password file should be read-only and only accessible by the operating system user Tomcat is running as. (意思是password.file的讀寫權限是400,僅運行tomcat服務的操做系統用戶能夠訪問)spa


     服務器上啓動Tomcat,本地運行jvisual.exe配置JMX,鏈接遠程Tomcat進行監控。操作系統

    wKiom1aD2fngYlLLAAC0B-3Ec5s765.png

  

     傳送門:溯本逐源之visualvm jmx鏈接:http://visualvm.java.net/jmx_connections.html .net

相關文章
相關標籤/搜索