在 Windows 上使用 JDK 1.4 监控 Tomcat 5.5
根据此文档 http://tomcat.apache.org/tomcat- 5.5-doc/monitoring.html#Enabling_JMX_Remote 应该可以远程监控在 JDK 1.4 上运行的 Tomcat 5.5 服务器,但在搜索了整个网络并尝试了多个操作系统之后,我仍然没有比第一天更进一步。 到目前为止我的结果是。使用标准设置 Tomcat
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=%my.jmx.port%
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=localhost
在 JDK 1.5 及更高版本上不会出现任何问题。 调试 Tomcat 使我可以访问 MBeanServer,但无法从外部连接到它。根据维基百科的信息 http://en.wikipedia.org/wiki/Java_Management_Extensions 我只需要一个工作连接器,但我不知道如何让它工作。
尝试根据 来设置 HTTP 适配器
<Connector port="${AJP.PORT}"
handler.list="mx"
mx.enabled="true"
mx.httpHost="${JMX.HOST}"
mx.httpPort="${JMX.PORT}"
protocol="AJP/1.3" />
根本没有效果。当我调试时,看起来属性 handler.list 和 mx.* 几乎被忽略了。我知道我应该只使用 JDK 1.5,这样我的担忧就会消失,但我们有大量 JDK 1.4 的遗留安装基础,如果我们可以使用 JMX 监控,那就太好了。 最终我想使用 JConsole 或 JVisualVM 连接到 Tomcat,据我所知,连接 URL 看起来像
service:jmx:rmi:///jndi/rmi://localhost:8888/jmxrmi
8888 是我的 JMX 端口。 如果有人对如何深入问题的根源有一些建议或想法,那将非常有帮助。
According to this documentation http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html#Enabling_JMX_Remote it should be possible to remotely Monitor a Tomcat 5.5 Server running on a JDK 1.4 but after searching all over the web and trying multiple OSs I still am no further than on day one.
My results thus far are. Settign up Tomcat with the standard
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=%my.jmx.port%
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=localhost
will work without any problems on JDK 1.5 and up.
Debugging into Tomcat gives me access to the MBeanServer but I am not able to connect to it from the outside. According to the info from Wikipedia http://en.wikipedia.org/wiki/Java_Management_Extensions
I just need a working connector and I have no idea how to get that working.
Trying to set up the HTTP Adaptor according to
<Connector port="${AJP.PORT}"
handler.list="mx"
mx.enabled="true"
mx.httpHost="${JMX.HOST}"
mx.httpPort="${JMX.PORT}"
protocol="AJP/1.3" />
has no effect at all. When I debugged it almost seemed like the attributes handler.list and mx.* were just ignored. I know I should just use JDK 1.5 and my worries would be gone but we have a large legacy install base of JDK 1.4 and it would be great if we could use the JMX monitoring.
Eventually I want to use either JConsole or JVisualVM to connect to the Tomcat and as far as I have understood the connection URL would look like
service:jmx:rmi:///jndi/rmi://localhost:8888/jmxrmi
were 8888 is my JMX port.
If anyone has some advice or ideas on how to drill to the root of the problem that would be very helpfull.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 1.5 (JDK5) 开始,Java 中就添加了 JMX 支持。要与 JDK 1.4 一起使用,必须下载并安装扩展 http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp 。我没有使用它,但这可能是一个起点(来自 http:// java.sun.com/developer/technicalArticles/J2SE/jmx.html)
要从外部连接,请尝试移除线路
如果您使用的是 Linux,请像 @vinothkr 所说的那样,解决 JMX 远程连接上的 localhost 问题(文件 /etc/hosts,将 127.0.0.1 替换为主机名所在行的服务器 IP)出现服务器的信息)。对于 Windows,我认为同样的事情也适用。
关于连接器,它是您阅读的文档上的jmx远程端口上的连接器。您在协议 AJP/1.3 上的 server.xml 上设置的连接器不相关。它涉及 Apache HTTPd(或其他 Web 服务器/负载均衡器)和 Tomcat 之间的通信。
JMX support had been added to Java since 1.5 (JDK5). To use it with JDK 1.4, an extension have to be dowloaded and installed http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp . I did'n used it but that could be a starting point (from http://java.sun.com/developer/technicalArticles/J2SE/jmx.html )
To connect from the outside, try to remove the line
If your are using Linux, do like @vinothkr said for localhost resolving issue on JMX remote connection (file /etc/hosts, replace 127.0.0.1 with the server IP on the line where the hostname of the server appear). For Windows, I think the same thing could applied.
About the connector, it's the connector on your jmx remote port on the documentation you read. The connector you had setup on server.xml on protocol AJP/1.3 is not related. It concern communication between Apache HTTPd (or other Web Server / Load Balancer) and Tomcat.
如果您能够连接到在 Windows 计算机上运行的 JVM。那么问题出在你的hosts.conf上,
尝试hostname -i,如果它报告127.0.0.1,那么就有问题了,
检查这个常见问题解答5。
http://download.oracle.com/javase/1.5 .0/docs/guide/management/faq.html
由于 JMX 使用端口重定向。这会导致问题
If you were able to connect to JVM running on Windows machines. Then the problem is your hosts.conf
Try hostname -i if it reports 127.0.0.1 then there is a problem
Check this FAQ no 5.
http://download.oracle.com/javase/1.5.0/docs/guide/management/faq.html
As JMX uses port redirection. This causes problem
你定义了远程服务器吗?
do you have the remote server defined?