开启JMX端口,进行数据采集,开启后kafka-topic.sh
等shell脚本报端口占用错误。
尝试办法
参考github中的解决办法后,kafka-topic.sh等shell脚本报端口占用错误解决,但是JMX的信息无法获取;
# github中的解决办法,但是只能保证shell脚本使用,但是未创建JMX端口
fi
}
# need to check if called to start server or client
# in order to correctly decide about JMX_PORT
ISKAFKASERVER="false"
if [[ "$*" =~ "kafka.Kafka" ]]; then
ISKAFKASERVER="true"
fi
base_dir=$(dirname $0)/..
# JMX port to use
if [ $JMX_PORT ] && [ -z "$ISKAFKASERVER" ]; then
KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi
# 端口信息
JMX_PORT=8888
[root@kafka2 bin]# netstat -anpt|grep LISTEN
tcp6 0 0 :::9092 :::* LISTEN 54162/java
tcp6 0 0 :::2181 :::* LISTEN 7615/java
# 因为没有jmx端口,导致如下报错
Trying to connect to JMX url: service:jmx:rmi:///jndi/rmi://172.16.205.106:8888/jmxrmi.
Could not connect to JMX url: service:jmx:rmi:///jndi/rmi://172.16.205.106:8888/jmxrmi. Exception Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 172.16.205.106; 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: 172.16.205.106; nested exception is:
如何能将两者兼容,开启jmx的同时可以获取命令行信息?
你的答案