Java在jdk5开始就自带有Jconsole了,要想用Jconsol监控且需要添加启动参数:

Linux系统:
JAVA_OPTS="$JAVA_OPTS 
    -Dcom.sun.management.jmxremote.port=8950
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false"
Windows系统也类似,去掉双引号,将环境变量符号$JAVA_OPTS 变成现在%JAVA_OPTS %即可。

这样就能在本机使用Jconsole监控了:jconsole localhost:8950。

要实现远程监控还要与IP绑定,添加参数:
    -Djava.rmi.server.hostname=192.168.10.31

若要实现使用用户名登陆,修改参数-Dcom.sun.management.jmxremote.authenticate=true;
    添加启动参数:-Dcom.sun.management.jmxremote.password.file=$JAVA_HOME/jre/lib/management/jmxremote.password ;
然后进行以下配置:
1. 把 JRE_HOME/lib/management/jmxremote.password.template拷贝为jmxremote.password。
2. 去掉此目录下 jmxremote.aclearcase/" target="_blank" >ccess 最后两行的注释,这个存的就是用户名和权限。
3. 对应的,去掉 jmxremote.password 最后两行注释,这个是用户名和对应的密码。
4. 通过添加和修改这两个文件来管理登陆用户。

最后,要修改jmxremote.password文件的权限chkmod 600 jmxremote.password。
   就可以在Jconsole里实现远程监控了:
   远程进程 192.168.10.31:8950 
   或 service:jmx:rmi:///jndi/rmi://192.168.10.31:8950/jmxrmi


利用JMX监控Tomcat运行情况,需要手工调整启动参数,如下:

打开cataline.bat,增加一行

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=10090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"

linux下修改cataline.sh:
JAVA_OPTS="-Dcom.sun.management.jmxremote.port=10090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=%CATALINA_BASE\conf\logging.properties"

注意JDK\jre\lib\management\management.properties文件必须存在。

重新启动tomcat节点,然后用jconsole连接(此处端口wei10090)


在正常的系统运行中,经常会有需求需要监控到tomcat运行的各项指标,如此的话,最简单的办法就是打开jmx服务,这样
可以比较方便的获取到tomcat运行的各项参数,甚至可以进行一些服务的关闭,重启等操作。
添加JMX服务监控到tomcat的方法很简单,将catalina.sh/catalina.bat文件中添加下面内容即可,端口号可以自定。
CATALINA_OPTS=-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false
有些网站上的文章将第一行取消
-Dcom.sun.management.jmxremote
不知道是否合适,如果你看过tomcat官方的帮助文档的话,你就知道虽然那样可以运行,但不是标准的设置。
http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html
上面的简单配置,是不需要密码验证的,jboss这方面不错,直接提供了密码验证的文件,tomcat需要手动添加。
CATALINA_OPTS=-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access \
将验证的选项设置为true之后,就可以设置用户名和密码以及访问权限了。
编辑设置权限的文件 $CATALINA_BASE/conf/jmxremote.access
monitorRole readonly
controlRole readwrite
编辑密码文件: $CATALINA_BASE/conf/jmxremote.password
monitorRole tomcat
controlRole tomcat
密码文件必须设置为只读权限并且仅供运行tomcat的用户访问


Enabling JMX Remote

Note: This configuration is needed only if you are going to monitor Tomcat remotely. It is not needed if you are going to monitor it locally, using the same user that Tomcat runs with.

The Oracle website includes the list of options and how to configure JMX Remote on Java 6: http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html.

The following is a quick configuration guide for Java 6:

Add the following parameters to setenv.bat script of your Tomcat (see RUNNING.txt for details).
Note: This syntax is for Microsoft Windows. The command has to be on the same line. It is wrapped to be more readable. If Tomcat is running as a Windows service, use its configuration dialog to set java options for the service. For un*xes remove "set " from beginning of the line.

set CATALINA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=%my.jmx.port%
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
  1. If you require authorization, add and change this:

      -Dcom.sun.management.jmxremote.authenticate=true
    -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password
    -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access
  2. edit the access authorization file $CATALINA_BASE/conf/jmxremote.access:
    monitorRole readonly
    controlRole readwrite
  3. edit the password file $CATALINA_BASE/conf/jmxremote.password:
    monitorRole tomcat
    controlRole tomcat

    Tip: The password file should be read-only and only accessible by the operating system user Tomcat is running as.

Note: The JSR 160 JMX-Adaptor opens a second data channel on a random port. That is a problem when you have a local firewall installed. To fix it, configure a JmxRemoteLifecycleListener, as described inlisteners documentation.

如何在Jconsole 监控 Jboss Tomcat的更多相关文章

  1. JConsole监控远程Tomcat服务器

    为了解决内存溢出的问题,会用到一些监视内存的工具,jconsole这个工具在jdk1.7自带了.这个工具可以查看系统的堆,非堆,线程,等等的一些整体的情况,从而可以判断出系统的一个大概的性能情况. c ...

  2. JConsole监控远程Tomcat服务器 遇到的坑

    1. 报错 JConsole  java net socketException: Connection reset 解决: 先查看linux服务器开放了哪些端口 netstat -ntpl 选中了一 ...

  3. 如何使用JCONSOLE 监控eclipse的tomcat

    在默认情况下,使用jconsole 监控本地tomcat 是不需要任何配置的,直接连接就可以监控tomcat.   但是在eclipse 下启动是监控不了.   解决方法:   设置jvm参数:   ...

  4. 通过jconsole监控tomcat JVM 内存、线程、CPU

    从Java 5开始 引入了 JConsole,来监控 Java 应用程序性能和跟踪 Java 中的代码.jconsole是JDK自带监控工具,只需要找到 JDK 安装路径,打开 bin 文件夹,双击  ...

  5. Jconsole 监控tomcat

    通过jconsole监控可以获取监控tomcat的相关的数据信息 如何通过代码来获取其中的线程和内存状况呢? 首先要配置好jconsole监控的相关配置,一搜基本就是那一个, 配置配不好的话接下来的工 ...

  6. JConsole监控Linux上的Tomcat

    JConsole监控Linux上的Tomcat 从Java 5开始引入了 JConsole,来监控 Java 应用程序性能和跟踪 Java 中的代码.jconsole是JDK自带监控工具,只需要找到 ...

  7. jconsole监控远程linux tomcat运行情况的配置 (转)

    来自:http://zhumeng8337797.blog.163.com/blog/static/100768914201242494649455/ 步骤如下: 1.编辑tomcat/bin/cat ...

  8. jconsole监控tomcat

    一.专业术语 GC垃圾回收机制:当需要分配的内存空间不再使用的时候,JVM将调用垃圾回收机制来回收内存空间. JMX(Java Management Extensions,即Java管理扩展)是一个为 ...

  9. 使用jconsole监控tomcat(推荐配置)

    1.在tomcat启动过程中,开启相应的参数配置 $Tomcat_home/bin/catalina.sh: 1 2 3 4 -Dcom.sun.management.jmxremote -Dcom. ...

随机推荐

  1. 洛谷——P1068 分数线划定

    P1068 分数线划定 题目描述 世博会志愿者的选拔工作正在 A 市如火如荼的进行.为了选拔最合适的人才,A 市对 所有报名的选手进行了笔试,笔试分数达到面试分数线的选手方可进入面试.面试分数线根 据 ...

  2. BestCoder Round #65 (ZYB's Premutation)

    ZYB's Premutation Accepts: 220 Submissions: 983 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...

  3. [BZOJ4709][JSOI2011]柠檬(斜率优化DP)

    显然选出的每一段首尾都是相同的,于是直接斜率优化,给每个颜色的数开一个单调栈即可. #include<cstdio> #include<vector> #include< ...

  4. 【图论】Popular Cows

    [POJ2186]Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 34752   Accepted: ...

  5. 【POJ】1088滑雪

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 97335   Accepted: 36911 Description ...

  6. python3-开发进阶Django-form组件中model form组件

    Django的model form组件 这是一个神奇的组件,通过名字我们可以看出来,这个组件的功能就是把model和form组合起来,先来一个简单的例子来看一下这个东西怎么用:比如我们的数据库中有这样 ...

  7. [转]SpringMVC拦截器详解[附带源码分析]

      目录 前言 重要接口及类介绍 源码分析 拦截器的配置 编写自定义的拦截器 总结 前言 SpringMVC是目前主流的Web MVC框架之一. 如果有同学对它不熟悉,那么请参考它的入门blog:ht ...

  8. 最简单的flask表单登录

    from flask import Flask from flask import request app = Flask(__name__) @app.route('/', methods=['GE ...

  9. Do waiting or suspended tasks tie up a worker thread?

      https://blogs.msdn.microsoft.com/askjay/2012/07/29/do-waiting-or-suspended-tasks-tie-up-a-worker-t ...

  10. es6,async简单总结

    1.简单来讲就是把函数变为异步操作的 async function demo() { let result = Math.random(); console.log(result); } 2.asyn ...