Java 解释 JMX URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2768087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Explain JMX URL
提问by priyank
I am trying to understand a JMX service URL.
我正在尝试了解 JMX 服务 URL。
service:jmx:rmi://192.168.30.10:1234/jndi/rmi://192.168.30.10:2344/jmxrmi
It would be great, if someone can help me understand this.
如果有人能帮助我理解这一点,那就太好了。
Thanks
谢谢
采纳答案by David Tonhofer
I will reuse an answer I wrote up earlier for this question: Cannot connect to Tomcat's MBeanServer via jconsole in Java6
我将重用我之前为这个问题写的答案:Cannot connect to Tomcat's MBeanServer via jconsole in Java6
It's not complete, but might help:
它不完整,但可能会有所帮助:
Suppose you have the JMX Server (alias 'JMX Agent' alias 'the JVM you want to connect to') running on 'TARGET MACHINE' with the RMI registry portat 'RMI REGISTRY PORT' and the JMX RMI server portat 'JMX RMI SERVER PORT'.
假设您在“目标机器”上运行 JMX 服务器(别名“JMX 代理”,别名“您想要连接的 JVM”),其RMI 注册表端口位于“RMI REGISTRY PORT”,JMX RMI 服务器端口位于“JMX RMI”服务器端口'。
Note:
笔记:
- The RMI registrytells JMX clients where to find the JMX RMI server port; information can be obtained under key
jmxrmi
. - The RMI registry portis generally known as it is set through system properties at JVM startup.
- The JMX RMI server portis generally notknown as the JVM chooses it at random (if no other precautions are taken).
- 在RMI注册表告诉JMX客户端在哪里可以找到JMX RMI服务器端口; 可以在 key 下获得信息
jmxrmi
。 - 在RMI注册表端口通常是已知的,因为它是通过在JVM启动系统属性中设置。
- 在JMX RMI服务器端口通常不被称为JVM随机选择它(如果不采取预防措施,其他)。
The following URI will lead to successful connection (tested)
以下 URI 将导致连接成功(已测试)
service:jmx:rmi://<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
service:jmx:rmi://<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
This looks nasty. Let's cut it apart.
这看起来很恶心。让我们把它分开。
This URI is an RFC2609 "Service Location Protocol URL" (well, it's really an URI, right?)
这个 URI 是一个 RFC2609“服务位置协议 URL”(嗯,它真的是一个 URI,对吧?)
It is composed of:
它由以下组成:
service
- a constantjmx:rmi
- the service typecomposed of: abstract typejmx
and URL schemermi
- the rest - the sap(service access protocol specification)
service
- 一个常数jmx:rmi
-服务类型由:抽象类型jmx
和URL 方案组成rmi
- 其余 - sap(服务访问协议规范)
sapis decomposed into:
sap分解为:
//<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>
- ipsite/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
- URL part
//<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>
- 网站/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
- 网址部分
A well-informed JMX client connects to the "ipsite" to do JMX-over-RMI exchanges; but what of the JMX client that doesn't KNOW that port? Patience...
消息灵通的 JMX 客户端连接到“ipsite”以进行 JMX-over-RMI 交换;但是不知道那个端口的 JMX 客户端呢?耐心...
URL partis decomposed into:
URL部分分解为:
/jndi/
- This seems to tell the JMX client that it can get lookup information at the location that followsrmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
- Yep, we get information about the JMX RMI Server at the RMI registry, under the lookup keyjmxrmi
/jndi/
- 这似乎告诉 JMX 客户端它可以在后面的位置获取查找信息rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
- 是的,我们在 RMI 注册中心的查找键下获得了有关 JMX RMI 服务器的信息jmxrmi
This is somewhat cart-before-horse, as one has to contact the RMI registrygiven by the latterpart of the SLP URL first.
这有点像先入为主,因为必须首先联系SLP URL后半部分给出的RMI 注册。
After scratching head, intuitively, let's try:
挠头之后,凭直觉,我们试试:
service:jmx:rmi://<TARGET_MACHINE>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
service:jmx:rmi://<TARGET_MACHINE>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Yes, that works! The JMX RMI server port is nicely obtained from the registry. On second thoughts, the target machineshould also be obtained from the registry, thus:
是的,这有效!JMX RMI 服务器端口可以很好地从注册表中获得。再想一想,目标机器也应该从注册表中获取,因此:
service:jmx:rmi:///jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
service:jmx:rmi:///jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Even better, that works, too!
更好的是,这也有效!
References:
参考:
- http://download.oracle.com/javase/6/docs/api/javax/management/remote/rmi/package-summary.html
- http://download.oracle.com/javase/6/docs/api/javax/management/remote/JMXServiceURL.html
- http://mx4j.sourceforge.net/docs/ch03s04.html
- http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdevg
- http://www.rfc-editor.org/rfc/rfc2609.txt
- http://download.oracle.com/javase/6/docs/api/javax/management/remote/rmi/package-summary.html
- http://download.oracle.com/javase/6/docs/api/javax/management/remote/JMXServiceURL.html
- http://mx4j.sourceforge.net/docs/ch03s04.html
- http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdevg
- http://www.rfc-editor.org/rfc/rfc2609.txt
回答by stacker
According to javax.management.remote.rmi
this url is assembled like this
这个网址是这样组装的
service:jmx:rmi://ignoredhost/jndi/rmi://myhost/myname
回答by Prolancer
To explain:
解释:
service:jmx:rmi://192.168.30.10:1234/jndi/rmi://192.168.30.10:2344/jmxrmi
service:jmx:rmi://192.168.30.10:1234
- says that there is a JMX Agent on the machine with IP address 192.168.30.10. The JMX agent is using (TCP) port 1234 to provide JMX service(s) over RMI (basically acts as an RMI server)./jndi/rmi://192.168.30.10:2344/jmxrmi
- says that the RMI stub to interact with the JMX Agent over RMI can be found in the RMI registry which is running on the machine with IP address 192.168.30.10 and is using (TCP) port 2344. To get the RMI stub you need to lookup the "jmxrmi" binding.
service:jmx:rmi://192.168.30.10:1234
- 表示在 IP 地址为 192.168.30.10 的机器上有一个 JMX 代理。JMX 代理使用 (TCP) 端口 1234 通过 RMI 提供 JMX 服务(基本上充当 RMI 服务器)。/jndi/rmi://192.168.30.10:2344/jmxrmi
- 表示通过 RMI 与 JMX 代理交互的 RMI 存根可以在 RMI 注册表中找到,该注册表在 IP 地址为 192.168.30.10 的机器上运行并使用(TCP)端口 2344。要获取 RMI 存根,您需要查找“jmxrmi”绑定。
Previous answers suggest that the 2nd part of the URL is to obtain the server port of the JMX RMI server. That is not correct. The JMX RMI server port is (TCP) 1234 and is part of the URL. What you get from the RMI registry is the RMI stub (javax.management.remote.rmi.RMIServerImpl_Stub
) which you can use to talk to JMX Agent (MBean Server) over RMI.
以前的答案表明 URL 的第二部分是获取 JMX RMI 服务器的服务器端口。那是不正确的。JMX RMI 服务器端口是 (TCP) 1234 并且是 URL 的一部分。您从 RMI 注册表中获得的是 RMI 存根 ( javax.management.remote.rmi.RMIServerImpl_Stub
),您可以使用它通过 RMI 与 JMX 代理(MBean 服务器)对话。
Hope this helps.
希望这可以帮助。