How to restart kafka server properly?

Zeinab Akhavan picture Zeinab Akhavan · Jul 19, 2018 · Viewed 25.6k times · Source

Every time I stop the kafka server and start it again it doesn't start properly and I have to restart my whole machine and start the kafka server. Does anybody know how I can restart kafka server without having to restart my machine? Actually I would like to terminate the consumer from last session.

Thank you,

Zeinab

Answer

Giorgos Myrianthous picture Giorgos Myrianthous · Jul 19, 2018

If your Kafka broker is running as a service (found under /lib/systemd/system/) from a recent Confluent Platform release, you can stop it using:

systemctl stop confluent-kafka.service

or if you'd like to restart the service,

systemctl restart confluent-kafka.service

Otherwise, you can stop your broker using

./bin/kafka-server-stop.sh

and re-start it:

./bin/kafka-server-start.sh config/server.properties

If you want to stop a specific consumer, simply find the corresponding process id:

ps -ef | grep consumer_name

and kill that process:

kill -9 process_id