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. Container With Most Water(LintCode)

    Container With Most Water Given n non-negative integers a1, a2, ..., an, where each represents a poi ...

  2. Trie树【P3879】 [TJOI2010]阅读理解

    Description 英语老师留了N篇阅读理解作业,但是每篇英文短文都有很多生词需要查字典,为了节约时间,现在要做个统计,算一算某些生词都在哪几篇短文中出现过. Input 第一行为整数N,表示短文 ...

  3. RabbitMQ (十三) 集群+单机搭建(window)

    拜读了网上很多前辈的文章,对RabbitMQ的集群有了一点点认识. 好多文章都说到,RabbitMQ的集群分为普通集群和镜像集群,有的还加了两种:单机集群和主从集群. 我看来看去,看了半天,怎么感觉, ...

  4. [BZOJ 2668] 交换棋子

    Link: BZOJ 2668 传送门 Solution: 重点在于对于每条转移路径:首尾算一次,中间节点算两次 可以一点拆三点,将原流量拆成入流量和出流量 但其实也可以就拆两点,分前后是否是一首尾点 ...

  5. android:scrollbarStyle属性及滚动条和分割线覆盖问题

    android:scrollbarStyle可以定义滚动条的样式和位置,可选值有insideOverlay.insideInset.outsideOverlay.outsideInset四种. 其中i ...

  6. 二叉搜索树BStree

    二叉搜索树,实际上是有点类似于二分查找.实际上很简单,就是递归.直接上代码,有点要注意的就是删除的时候,如果是左子树和右子树都存在的话,要寻找继承者(successor). import java.u ...

  7. mysql函数的使用create function myfunction(...

    use test   //必须在某个数据库下面创建 delimiter $ //创建 CREATE FUNCTION myFunction(ln int, ls int)   //参数这里不能加def ...

  8. Java如何判断线程池所有任务是否执行完毕

    import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Tes ...

  9. NHibernate 继承映射(第十六篇)

    在NHibernate的映射中,关于继承的映射策略有3种方式 单表继承 类表继承 具体表继承 另外还有一种比较特别的多态映射 隐式多态 下面分别来阐述NHibernate继承映射的各种策略要点. 一. ...

  10. js模板引擎-art-template常用

    art-template javascript 模板引擎 分为原生语法和简洁语法,本文主要是讲简洁语法 基础数据渲染 输出HTML 流程控制 遍历 调用自定义函数方法 子模板引入 基础数据渲染 一.引 ...