JConsole是从Java 5中开始引入的一个用于对JVM性能和资源消耗进行监控的图形化工具。JConsole可以连接本地的Java程序,也可以连接远程的Java程序。jconsole的可执行文件在JAVA_HOME的bin目录下。
可以直接jconsole运行,然后使用GUI选择connect哪个程序。或者
jconsole process_id
这种方式适用于jconsole和application运行在同一台机子上。
jconsole hostname:port_number
这种方式适用于jconsole连接到远程主机到应用上。
可以监控memory,threads,classes, CPU usage, VM information, mbeans等资源信息。
要实现让JConsole可以远程连接到某个Java程序,则需要在Java程序启动的JAVA_OPTION中添加选项:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999”来指定远程管理的端口。
用这些参数来表达是否jmx连接的时候需要验证和ssl连接。
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
问题:
jconsole本地连接可以,远程连接失败,失败信息如下:
Connection Failed: Retry? The connection to ... did not succeed. Would you like to try again?
这是因为在启动程序的时候少了一个参数:
-Djava.rmi.server.hostname=192.168.52.11
要告诉启动rmi server。
http://docs.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html
原文:http://blog.csdn.net/hongchangfirst/article/details/50070161
作者:hongchangfirst
hongchangfirst的主页:http://blog.csdn.net/hongchangfirst