Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kafka command raise 'Address Already in used' after configuration #983

Closed
vhp1360 opened this issue Jul 8, 2024 · 11 comments
Closed

kafka command raise 'Address Already in used' after configuration #983

vhp1360 opened this issue Jul 8, 2024 · 11 comments

Comments

@vhp1360
Copy link

vhp1360 commented Jul 8, 2024

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

@dhoard
Copy link
Collaborator

dhoard commented Jul 8, 2024

@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.

@vhp1360
Copy link
Author

vhp1360 commented Jul 9, 2024

thanks for reply, could you please provide a link.
I'm doing according this document.

@dhoard
Copy link
Collaborator

dhoard commented Jul 9, 2024

@vhp1360
Copy link
Author

vhp1360 commented Jul 11, 2024

thank you, i'm checking in next days and reply.

@vhp1360
Copy link
Author

vhp1360 commented Jul 17, 2024

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

@dhoard
Copy link
Collaborator

dhoard commented Jul 17, 2024

"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.

@vhp1360
Copy link
Author

vhp1360 commented Jul 23, 2024

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?

@dhoard
Copy link
Collaborator

dhoard commented Jul 24, 2024

The integration depends on how you are starting components. If you are using systemd, you can define EXTRA_ARGS in the systemd configuration value.

@vhp1360
Copy link
Author

vhp1360 commented Jul 24, 2024

no I use source.
I tried to add it in properties file either kafka-run-class.sh but not working.

@dhoard
Copy link
Collaborator

dhoard commented Jul 24, 2024

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`

@vhp1360
Copy link
Author

vhp1360 commented Jul 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants