使用Jconsole对java的内存使用情况(JVM)进行监控.doc
文本预览下载声明
JDK1.5提供JMX remote的管理工具Jconsole,可以监控Java运行程序的内存使用情况、活动线程数量、类装载的数量、MBeans的状态、虚拟机的各种信息等,还可以执行MBean公开的方法或强制进行垃圾回收。因为Apusic应用服务器实现标准的JMX接口,因此也可以使用Jconsole进行监控。
下面是在windows端对Linux的java应用(Resin)的JVM进行监控。windows: 安装 jdk1.6.0_06? /javase/downloads/index.jspLinux:Resin2.1.x + jdk1.6
启动resin ,增加jvm监控的指令:可以在java启动参数添加,如: httpd.sh? 或者 wrapper.pl 里面vi http.sh args=*** 把 需要启动jvm选项加入。
#指定远程服务器的端口-Dcom.sun.management.jmxremote.port=12345#指定远程服务器的用户认证-Dcom.sun.management.jmxremote.password.file=$JRE_HOME/lib/management/perties -Dcom.sun.management.jmxremote.access.file=$JRE_HOME/lib/management/perties
使用密码:#JRE_HOME/lib/management/jmxremote.password.templatecp jmxremote.password.template pertieschmod 600 perties#默认用户名 密码为:monitorRole QEDcontrolRole RD#默认权限#cp jmxremote.access perties? #设置权限monitorRole?? readonlycontrolRole?? readwrite
#也可以使用禁止用户认证com.sun.management.jmxremote.authenticate=false
也可以使用ssl连接
这里先不用com.sun.management.jmxremote.ssl=false
说明: 如果没有启动com.sun.management.jmxremote 的配置 , 远程连接会提示:error during jrmp connection establishment ; nested exception is
如果无法连接有可能是linux服务器的hostname存在问题
#修改hostname/etc/hosts? 把修改为外网卡IP,如00还有/etc/sysconfig/network
#启动resin$RESIN_HOME/bin/http.sh start#查看是否已经启动#ps -x8681 pts/0??? S????? 0:00 perl bin/wrapper.pl -chdir -name httpd -class com.caucho.server.http.HttpServer -J-server -verbose -Dcom.8683 pts/0??? Sl???? 0:04 /home/2/jdk1.6.0_06/bin/java -server -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremo#查看端口#netstat -antcp??????? 0????? 0 :35844???????????? :35848???????????? ESTABLISHEDtcp??????? 0????? 0 :::8080???????????????????? :::*??????????????????????? LISTENtcp??????? 0????? 0 :::12345??????????????????? :::*??????????????????????? LISTEN
-Dcom.sun.management.jmxremote.authenticate=false #是否使用ssl-Dcom.sun.management.jmxremote.ssl=false
windows下jconsole命令在 $JAVA_HOME/bin 下
cmd:\jconsole#启动
窗体底端
?
?
?
?
连接远程00:12345controlRole RD
?
?
?
?
?
?
窗体底端
窗体顶端
窗体底端
窗体顶端
?
?
窗
显示全部