天天看點

jconsole配置遠端監控

java -Djava.rmi.server.hostname=192.168.111.96 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9996 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false Test

下面從網看到的一片文章帶認證的

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

在windows上使用jconsole做本地監控很簡單,隻需要在cmd視窗中輸入jconsole回車,然後在彈出的界面中選擇本地程序連接配接即可。下面主要說明一下遠端監控的實作。

環境:

伺服器端: Linux + jdk1.5.0 + resin3

用戶端: Windows + jdk1.5.0

====================

jconsole遠端監視的配置步驟如下:

伺服器端:

1. mkdir $JAVA_HOME/jconsole_pwd

2. cp $JAVA_HOME/jre/lib/management/jmxremote.password.template $JAVA_HOME/jconsole/jmxremote.password -> chmod 600 $JAVA_HOME/jconsole/jmxremote.password

3. vi jmxremote.password 去掉#monitorRole RED前的注釋并将RED修改為你要設定的密碼。(安全起見,隻開放有隻讀權限的使用者)

4. 修改 $RESIN_HOME/bin/wrapper.pl,為$JAVA_ARGS添加三個參數:

-Dcom.sun.management.jmxremote.port=1010

-Dcom.sun.management.jmxremote.password.file=/usr/local/jdk1.5.0/jconsole_pwd/jmxremote.password

-Dcom.sun.management.jmxremote.ssl=false

5. 執行hostname -i ,如果顯示的是127.0.0.1,則需要修改/etc/hosts檔案

6. vi /etc/hosts,修改如下:

#127.0.0.1              localhost localhost.localdomain localhost

伺服器的真實IP位址        localhost localhost.localdomain localhost

具體原因是伺服器端解釋機器名的問題,相關問題見: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6209663

伺服器端配置參見: http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#remote

7. 啟動resin -> netstat -na|grep 1010 檢視1010端口是否已在監聽

用戶端:

1. 打開cmd視窗,輸入jconsole

2. 指定連接配接參數:

遠端主機: 伺服器的真實IP位址

端口: 1010 ($JAVA_ARGS中-Dcom.sun.management.jmxremote.port指定的端口)

使用者名: monitorRole (jmxremote.password中指定的使用者名)

密碼: your_password(jmxremote.password中設定的密碼)

3. 連接配接 -> OK。。。

用戶端配置參見: http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html

jconsole文檔位址:http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jconsole.html