文档详情

使用Jconsole对java的内存使用情况(JVM)进行监控.doc

发布:2017-06-10约2.03千字共5页下载文档
文本预览下载声明
JDK1.5提供JMX remote的管理工具Jconsole,可以监控Java运行程序的内存使用情况、活动线程数量、类装载的数量、MBeans的状态、虚拟机的各种信息等,还可以执行MBean公开的方法或强制进行垃圾回收。因为Apusic应用服务器实现标准的JMX接口,因此也可以使用Jconsole进行监控。 下面是在windows端对Linux的java应用(Resin)的JVM进行监控。 windows: 安装 jdk1.6.0_06? /javase/downloads/index.jsp Linux: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.template cp jmxremote.password.template perties chmod 600 perties #默认用户名 密码为: monitorRole QED controlRole RD #默认权限 #cp jmxremote.access perties? #设置权限 monitorRole?? readonly controlRole?? 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 -x 8681 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 -an tcp??????? 0????? 0 :35844???????????? :35848???????????? ESTABLISHED tcp??????? 0????? 0 :::8080???????????????????? :::*??????????????????????? LISTEN tcp??????? 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:12345 controlRole RD ? ? ? ? ? ? 窗体底端 窗体顶端 窗体底端 窗体顶端 ? ? 窗
显示全部
相似文档