---
title: "jconsole远程监控Java进程"
author: "zhengxuezhou"
date: "2012-05-07T11:44:19Z"
tags: []
categories: ["编程语言"]
slug: "jconsole-java"
draft: false
lastmod: "2012-05-07T11:44:19Z"
id: 1513786
url: "https://fire11.iteye.com/blog/1513786"
---

JDK中的工具jconsole可以很好地监控Java进程及其运行环境的情况。这里着重讲讲远程监控。
1、远程Java程序运行参数中增加
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=8888 （一个没有占用的端口)
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=true
    -Dcom.sun.management.jmxremote.password.file=
                       %JAVA_HOME%/jre/lib/management/jmxremote.password 
    -Dcom.sun.management.jmxremote.access.file=
                       %JAVA_HOME%/jre/lib/management/jmxremote.access
2、编辑文件%JAVA_HOME%/jre/lib/management/jmxremote.password
    如果不存在，就把jmxremote.password.template复制一份，然后改名。
    这个文件中存的是用户名和密码
   特别说明：
   文件jmxremote.password必须设置为只有所有者可访问。
   在Unix或Linux环境下执行下面命令即可
     chmod 600 jmxremote.password
   在windows环境下麻烦一点，参考下面：
   http://72.5.124.55/j2se/1.5.0/docs/guide/management/security-windows.html  
3、启动远程Java程序
4、启动jconsole




一  服务器端配置

在catalina.sh众加入
export JAVA_OPTS="$JAVA_OPTS
    -Djava.rmi.server.hostname=192.168.1.48
    -Dcom.sun.management.jmxremote.port=8950
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false"

二  client

开启一个jconsole 输入192.168.1.48:8950 就可以看到了

注意事项：注意防火墙是否开启