简体   繁体   English

JMX端口动态分配

[英]JMX Port dynamic allocation

I have 16 Java processes with the same main method and arguments running on one machine. 我有16个Java进程,在一台机器上运行相同的主方法和参数。 I wish to monitor these remotely thru JConsole. 我希望通过JConsole远程监控这些。

Hard coding port numbers like -Dcom.sun.management.jmxremote.port=5000 won't work because these processes are using same configuration and they can't work with same port. -Dcom.sun.management.jmxremote.port=5000这样的硬编码端口号将无法工作,因为这些进程使用相同的配置,并且无法使用相同的端口。

Is it possible for the JVM to select a different port dynamically for each of the 16 processes? JVM是否可以为16个进程中的每个进程动态选择不同的端口?

Using RMI Connector might be the way as you may specify URL of your agent. 使用RMI Connector可能就像指定代理的URL一样。

In case you'd need it, you may create RMI registry programatically using: 如果您需要它,您可以使用以下命令以编程方式创建RMI注册表:

java.rmi.registry.LocateRegistry.createRegistry(port);

You may find following unrelated sample useful: Connecting Through Firewall Using JMX 您可能会发现以下不相关的示例非常有用: 使用JMX连接防火墙

I don't think the oracle jvm supports anything like this. 我不认为 oracle jvm支持这样的东西。 the only thing that might work is using the port "0", which enables "dynamic" port selection in some rmi related stuff. 唯一可行的方法是使用端口“0”,它可以在一些rmi相关的东西中启用“动态”端口选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM