kafka command raise 'Address Already in used' after configuration
vhp1360 opened this issue · 11 comments
Hello
I face a issue.
I config my kafka cluster according documentation and I can gather metrics in premetheus, but after changing kafka-server-class.sh
file according the this project documentation, I couldn't run any kafka commands and I got Address Already in used
. this error raise for any ports which I set for java -javaagent:./jmx_prometheus_javaagent-0.20.0.jar=AnyPort:config.yaml -jar yourJar.jar
@vhp1360 for Kafka, you should integrate the JMX exporter at the component level.
For a broker, you should add it to KAFKA_OPTS
. Typically this is the configuration in the broker's systemd file.
Other components follow a similar scenario, but may use different environment variable names.
thanks for reply, could you please provide a link.
I'm doing according this document.
Here is a good reference: https://www.confluent.io/blog/monitor-kafka-clusters-with-prometheus-grafana-and-confluent/
thank you, i'm checking in next days and reply.
hello again.
I'm using Apache Kafka pre-build files.
I meant for example I run ~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.1.properties
to run kafka.
so, which file, should I add -javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=1234:/opt/prometheus/kafka_broker.yml'? as I told I added in
kafka/bin/kafka-run-class.sh`
I couldn't find my question in the provided link. It assumes we use the installed version.
thanks
"You can inject it by appending the KAFKA_OPTS variable or by adding an EXTRA_ARGS (variable)"
Define an environment variable EXTRA_ARGS
...
export EXTRA_ARGS="-javaagent:/opt/prometheus/jmx_prometheus_javaagent.0.15.0.jar=1234:/opt/prometheus/kafka_broker.yml"
When you run ...
~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.1.properties`
... the extras args will be added to the overall command.
thanks. It works. but it isnt suitable.
it is better to add it on config file or any file that automatically runs it.
could you please guide me on this?
The integration depends on how you are starting components. If you are using systemd, you can define EXTRA_ARGS
in the systemd configuration value.
no I use source.
I tried to add it in properties file either kafka-run-class.sh but not working.
What I suggested is the recommended/proper way to pass the extra arguments to Kafka when running kafka-server-start.sh
export EXTRA_ARGS="-javaagent:/opt/prometheus/jmx_prometheus_javaagent.0.15.0.jar=1234:/opt/prometheus/kafka_broker.yml"
~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.1.properties`
many thanks.my problem solved.
I add "-javaagent:/opt/prometheus/jmx_prometheus_javaagent.0.15.0.jar=1234:/opt/prometheus/kafka_broker.yml
in kafka-server-start.sh as EXTRA_ARGS="$EXTRA_ARGS -javaagent:/opt/prometheus/jmx_prometheus_javaagent.0.15.0.jar=1234:/opt/prometheus/kafka_broker.yml"
maybe changing the document which I mentioned at first, helps others