用于远程访问的 Jetty JMX 设置

djo*_*djo 6 linux jetty java jmx centos6

我在让 JMX 在 Jetty(9.1.3.v20140225) 上工作时遇到了一些问题,所以我已经阅读了关于这个的 Jetty doco。

所以我在jetty.conf中添加了以下内容

# ========================================================
# jetty.conf Configuration for jetty.sh script
# --------------------------------------------------------
# This file is used by the jetty.sh script to provide
# extra configuration arguments for the start.jar command
# created by that script.
#
# Each line in this file becomes an arguement to start.jar
# in addition to those found in the start.ini file
# =======================================================
jetty-logging.xml
jetty-started.xml
etc/jetty.xml
etc/jetty-jmx.xml
etc/jetty-jmx-remote.xml
Run Code Online (Sandbox Code Playgroud)

我添加了 jmx 作为 start.jar --add-to-start 命令的一部分,因为 doco 告诉我作为让 Jconsole 连接到 Jetty 的一部分

http://www.eclipse.org/jetty/documentation/current/jetty-jconsole.html

[mybase]$ java /opt/jetty-dist/start.jar --add-to-start=jmx
INFO: jmx-remote      initialised in ${jetty.base}/start.ini (appended)
INFO: jmx             initialised transitively
Run Code Online (Sandbox Code Playgroud)

当然,当我这样做时,它只添加了 jmx 而不是 jmx-remote,不知道为什么,但我希望有人可以让我知道原因。

在从我阅读的文档中说出所有这些时,我已经涵盖了他们想要实现的目标。

http://www.eclipse.org/jetty/documentation/current/jmx-chapter.html

但同样,就我在包中看到的而言,它所说的并不完全正确,因此我添加了 jetty-jmx-remote 的原因,因为 doco 所说的应该在 jetty-jmx.xml 中。

无论如何,当我启动 Jetty 时,我在日志文件中看到它正在启动

INFO:oejj.ConnectorServer:main: JMX 远程 URL: service:jmx:rmi://host:1099/jndi/rmi://host:1099/jmxrmi

我可以从服务器 telnet 到 1099,从我的客户端,我使用 nmap 只是为了仔细检查端口是否正在监听,并且还在 netstat 中看到它。当我使用 VisualVM 连接时,我只是收到一个错误。

我已经确保我已经打开了我的网络和码头位置之间的所有端口。

任何人都可以指出我正确的方向来实现这一目标。

谢谢

djo*_*djo 5

排序了,需要手动添加到start.ini

--module=jmx-remote
## JMX Configuration
## Enable for an open port accessible by remote machines
jetty.jmxrmihost=localhost
jetty.jmxrmiport=1099
## Strictly speaking you shouldn't need --exec to use this in most environments.
## If this isn't working, make sure you enable --exec as well
-Dcom.sun.management.jmxremote
Run Code Online (Sandbox Code Playgroud)

并在 jetty-jmx.xml 中更新了这一点。

<Call class="java.lang.System" name="setProperty">
    <Arg>java.rmi.server.hostname</Arg>
    <Arg>IP-Address</Arg>
  </Call>
Run Code Online (Sandbox Code Playgroud)

另外不需要做我对jetty.conf所做的事情。