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. css总结——position

    CSS(Cascading Style Sheet),中文翻译为层叠样式表,是用于控制网页样式并允许将样式信息与网页内容分离的一种标记性语言.在css控制页面中,主要有四种样式:行内样式(style ...

  2. 【拓展Lucas】模板

    求\(C_n^m \mod p\),写得太丑了qwq. 第一次写拓展Lucas竟然是在胡策的时候qwq写了两个半小时啊_(:з」∠)还写挂了一个地方qwq 当然今天胡策我也是第一次写中国剩余定理(ˇˍ ...

  3. cogs 2039. 树的统计

    2039. 树的统计 ★★   输入文件:counttree.in   输出文件:counttree.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] 关于树的统计问题有 ...

  4. 【AC自动机】【状压dp】【滚动数组】hdu6086 Rikka with String

    给你m个01串,问你有多少个长度为2L的01串,满足前半段倒置取反后等于后半段,并且包含所有的m个01串. 考虑单词完全在中线前面或者后面的情况,直接将单词及其倒置取反插入AC自动机,AC自动机每个结 ...

  5. 【最短路】【spfa】CDOJ1633 去年春恨却来时,落花人独立,微雨燕双飞

    对于S集合中的数,例如a1,考虑到如果x能够被表示出来,那么x+a1也一定能被表示出来 设d[r]为所有模a1余r的数中,能被表示出来的最小的数 用d[x]+ai去更新d[(x+ai)%a1],跑最短 ...

  6. [bzoj1011](HNOI2008)遥远的行星(近似运算)

    Description 直 线上N颗行星,X=i处有行星i,行星J受到行星I的作用力,当且仅当i<=AJ.此时J受到作用力的大小为 Fi->j=Mi*Mj/(j-i) 其中A为很小的常量, ...

  7. Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何

    C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...

  8. a标签点击后页面显示个false

    最近遇到个问题,在html页面中使用a标签,在href属性中调用一个function,而function中返回的是return false.结果页面被跳转了,然后页面上显示一个false. 一看到这个 ...

  9. 关于热插拔usb hotplug /proc/sys/kernel mdev udev b...

    转:http://www.360doc.com/content/10/0527/18/9922_29835045.shtml 这篇文章说的很好http://blog.chinaunix.net/u1/ ...

  10. 用JSP生成HTM网页,减轻数据库操作

    原文:http://www.jspkongjian.net/news.jsp?id=396 此教程的功能: 利用servlet 实现抓取一个网页,把这个网页保存为.htm  比如抓取我们的主页inde ...