如何在Jconsole 监控 Jboss Tomcat
2016-11-17 15:35
85 查看
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. href="http://biancheng.dnbcw.info/apache/" target=_blank>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.batscript 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
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
edit the access authorization file $CATALINA_BASE/conf/jmxremote.access:
monitorRole readonly controlRole readwrite
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监控tomcat
- 如何使用JCONSOLE 监控eclipse的tomcat
- jconsole 监控 tomcat使用情况如何配置
- 简述如何配置JConsole以实现对ArcGIS for Server的监控
- 如何使用jconsole监控tomcat
- JVM监控工具介绍jstack, jconsole, jinfo, jmap, jdb, jsta (Linux 如何查看进程的各线程的CPU占用 )
- 如何在 DB2 UDB 中监控死锁
- 如何在LoadRunner中监控oracle数据库-Zee
- 如何监控主窗体
- 如何有效监控.NET 应用程序
- 如何在 DB2 UDB 中监控死锁
- 如何通过LoadRunner监控Linux和Unix操作系统的资源状况
- 如何有效监控.NET 应用程序
- 如何对网站进行监控
- [转]使用JDK6 中的JConsole监控应用
- 【原】项目开发过程管理的关键是需求开发与管理,如何监控? 文/谷雨霖
- 如何使用Nagios实现网络监控?
- 如何对系统中的某个进程进行监控
- 在VB中如何用API监控鼠标和键盘
- IT监控工作如何引入热门的ITIL?