Search code examples
windowscmdapache-kafka

close Kafka via TERMINAL


Hi I'm newby Kafka and I succedded in starting a Kafka server in windows (via Terminal) follwing this documentation: https://dzone.com/articles/running-apache-kafka-on-windows-os https://kafka.apache.org/quickstart

My question is easy, how should I close KAfka correctly via cmd terminal in windows?

The problem is that when I close the different terminals (in order to shut down my computer) I'm not able to start it again beceause kafka runs out of memory and fataly crashes

 ERROR Error while loading log dir C:\Users\u1\Desktop\kafka-logs (kafka.log.LogManager)
java.io.IOException: Map failed
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:944)
        at kafka.log.AbstractIndex.<init>(AbstractIndex.scala:126)
.
Caused by: java.lang.OutOfMemoryError: Map failed
        at sun.nio.ch.FileChannelImpl.map0(Native Method)
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:941)

Is there any way to close my consumer, producer, topic, kafka and producer correctly using terminal comands?

enter image description here I found a lot of documentation about closing it via code but this is not my question. Closing a Kafka connection

-------- UPDATE------- I don´t know how to declare the winner of the solution because both (Robin Moffatt, Mukesh Prajapati) are right. Because when I press CTRL + C, my terminal asks me about closing the program that is executing. Also when I restart it, works perfectly. In the other hand the solution provided by Mukesh Prajapati also works like charm, as you can see in the following screen it closes the instance of the zookeper. (thanks both for your help) enter image description here


Solution

  • To shutdown Zookeeper, use following command:

    bin\windows\zookeeper-server-stop.bat config\zookeeper.properties
    

    To shutdown Kafka Server, use following command:

    bin\windows\kafka-server-stop.bat config\server.properties