JMX绑定到多个网络接口

时间:2018-07-25 21:33:20

标签: java jmx

是否可以将多个网络接口绑定到mbean应用程序,例如IPv4和IPv6?

到目前为止,我尝试使用2个指向不同网络接口的不同JMXServiceURL启动2个JMXConnectorServer。 在这种情况下,我得到了

Exception in thread "main" java.io.IOException: Cannot bind to URL [rmi://192.168.1.7:44448/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.1.7; nested exception is: 
java.net.ConnectException: Connection refused (Connection refused)]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:818)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)
at application.test.JMXAgent.main(JMXAgent.java:56)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.1.7; nested exception is: 
java.net.ConnectException: Connection refused (Connection refused)]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:157)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)
at javax.naming.InitialContext.bind(InitialContext.java:417)
at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:639)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)
... 1 more

在我启动的最后一个JMXConnectorServer上,我确实尝试过更改顺序,只是为了验证它是否是错误的URL,但后来我得到了另一个。

我还尝试了启动2个JMV,其中1个使用IPv4,1个使用IPv6

java -Dcom.sun.management.jmxremote \
 -Dcom.sun.management.jmxremote.port=1617 \
 -Dcom.sun.management.jmxremote.authenticate=false \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Djava.rmi.server.hostname=<IP>

在这种情况下,我上一次启动时遇到此错误:

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1617; nested exception is: 
java.net.BindException: Address already in use (Bind failed)

是否可以通过某种方式将其绑定到多个接口,还是需要启动具有2个不同端口的2个JVM?

感谢您抽出宝贵的时间阅读所有内容。

0 个答案:

没有答案