啟動JMX遠程功能,使用jConsole監控tomcat

來源:互聯網
上載者:User

在tomcat上測試的,理論上試用於任何JAVA進程,以及任何實現JMX規範的程式.

修改$CATALINA_HOME/bin/catalina.sh檔案,添加如下JVM參數

 -Dcom.sun.management.jmxremote.port=18100  //指定jmx串連連接埠

-Dcom.sun.management.jmxremote.authenticate=false  //This configuration is insecure. Any remote user who knows (or guesses) your JMX port number and host name will be
able to monitor and control your Java application and platform. While it may be acceptable for development, it is not recommended for production systems. 這個參數預設是enabled  

 -Dcom.sun.management.jmxremote.pwd.file=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/management/jmxremote.password 

-Dcom.sun.management.jmxremote.ssl=false  //預設是true,需要指定

 -Dcom.sun.management.jmxremote.pwd.file 這個參數指定的file路徑,預設是在$JRE_HOME/lib/management下,預設是只有一個jmxremote.password.template檔案,把這個檔案拷貝成jmxremote.password,修改最後2行指定使用者名稱密碼,如:monitorRole  123456(用jconsole串連的時候就用這對使用者名稱和密碼)當然,JVM參數

-Dcom.sun.management.jmxremote.authenticate=false 的時候,不用密碼就可以串連

啟用JMX還有很多另外的JVM參數可以配置,配置使用密碼串連以及使用SSL安全連線等等,不一個個去嘗試了,方法見http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html。

過程中還需要修改機器的hosts,

# vi /etc/hosts 

127.0.0.1   (修改成機器ip)                   localhost localhost.localdomain localhost

修改機器主機名稱的檔案(可不修改,但是要跟hosts匹配):/etc/sysconfig/network


注意:在catalina.sh檔案中添加上面這些JVM參數後,運行shutdown.sh的時候,會提示jmxremote連接埠被佔用,原因是運行shutdown.sh指令碼的時候會啟動一個JVM,又會嘗試綁定jmxremote的連接埠,導致這個問題。見https://issues.apache.org/bugzilla/show_bug.cgi?id=36976。暫時沒想辦法去解決它,直接kill進程了(應該可以通過配置解決)。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.