Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart kafka server properly?

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

like image 499
Zeinab Akhavan Avatar asked Jul 19 '18 17:07

Zeinab Akhavan


People also ask

What happens when Kafka broker restarts?

Safe Broker Restarts Once you are ready to start the broker back up, you can do so with a simple service kafka start. It will likely take a few minutes for the broker to recover after restarting. It needs to check all of its recent logs to make sure that it doesn't have any incomplete messages.

How do I stop Kafka server gracefully?

Go to the Kafka home directory and execute the command ./bin/kafka-server-start.sh config/server. properties . Stop the Kafka broker through the command ./bin/kafka-server-stop.sh .


2 Answers

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
like image 166
Giorgos Myrianthous Avatar answered Oct 21 '22 08:10

Giorgos Myrianthous


Or simply:

sudo systemctl restart kafka
like image 43
Mattia Baldari Avatar answered Oct 21 '22 09:10

Mattia Baldari