如何使用kafka.tools.jmxtool访问jmx度量?

eivnm1vs  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(697)

我无法使用bin/kafka-run-class.sh kafka.tools.jmxtool脚本获取jmx度量。但是,我可以使用jconsole连接到进程。
我设置了以下属性:

com.sun.management.jmxremote = true
com.sun.management.jmxremote.authenticate = false
com.sun.management.jmxremote.local.only = false
com.sun.management.jmxremote.port = 9145
com.sun.management.jmxremote.ssl = false

例外情况:

? kafka_2.11-2.1.0/bin/kafka-run-class.sh kafka.tools.JmxTool --jmx-url service:jmx:rmi:///jndi/rmi://kafkatest-01:9154/jmxrmi    
Trying to connect to JMX url: service:jmx:rmi:///jndi/rmi://kafkatest-01:9154/jmxrmi.
Could not connect to JMX url: service:jmx:rmi:///jndi/rmi://kafkatest-01:9154/jmxrmi. Exception Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: kafkatest-01; nested exception is: 
    java.net.ConnectException: Connection refused (Connection refused)].
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: kafkatest-01; nested exception is: 
    java.net.ConnectException: Connection refused (Connection refused)]
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
    at kafka.tools.JmxTool$.main(JmxTool.scala:120)
    at kafka.tools.JmxTool.main(JmxTool.scala)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: kafkatest-01; nested exception is: 
    java.net.ConnectException: Connection refused (Connection refused)]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:136)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1955)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1922)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
    ... 3 more
zqdjd7g9

zqdjd7g91#

Trying to connect to JMX url: service:jmx:rmi:///jndi/rmi://kafkatest-01:9154/jmxrmi.

但你的港口是9145

com.sun.management.jmxremote.port = 9145

想知道在运行的jvm上实际设置了哪些属性(对于检查这样的内容很有用)

prompt> jcmd $pid VM.system_properties

相关问题