Unable to start Zookeeper server in Apache Kafka

Viewed 15908

I am in kafka_home/bin/windows (as suggested here). Then I get the same problem as here, where it suggests to launch the program from the kafka home. I get this error when launching from the windows folder:

INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2014-08-21 11:53:55,748] FATAL Invalid config, exiting abnormally (org.apache.zookeeper.server.quorum.QuorumPeerMain)
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing config/zookeeper.properties
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:110)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:99)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:76)
Caused by: java.lang.IllegalArgumentException: config/zookeeper.properties file is missing
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:94)
    ... 2 more
Invalid config, exiting abnormally

Does anybody know how to solve this?

3 Answers

The problem here is the windows bat scripts are not properly tested. Also the documentation has not mentioned the prerequisites like installing scala, java and setting the ENV variables that zookeer and Kafka depends up on.

Here is what I did to resolve the problem and then zookeeper , kafka server has started properly, running fine. 1. Install scala and set the env variables SCALA_HOME, SCALA_VERSION , SCALA_BINARY_VERSION. Add the SCALA_HOME\bin to PATH. 2. Install java and set JAVA_HOME and add JAVA_HOME\bin to PATH. 3. CORRECT THE FILEs \bin\windows\zookeeper-server-start.bat AND \bin\windows\kafka-run-class.bat BY REPLACING ALL THE ENTRIES THE STRING %~dp0 WITH %CD% 4. CD AND RUN THE COMMAND TO START ZOOKEER : bin\windows\zookeeper-server-start.bat config\zookeeper.properties eg -> D:\apps\kafka_2.12-0.11.0.1>bin\windows\zookeeper-server-start.bat config\zookeeper.properties Zookeeper shoould start properly 5 CD AND RUN THE COMMAND TO START KAFKA SERVER : bin\windows\kafka-server-start.bat config\server.properties eg -> D:\apps\kafka_2.12-0.11.0.1>bin\windows\kafka-server-start.bat config\server.properties kafka server/broker should start properly 6. We can then test createing a topic and list the topics as mentioned in the kafka quick start guide her : https://kafka.apache.org/quickstart

D:\apps\kafka_2.12-0.11.0.1>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2
Created topic "test2".

D:\apps\kafka_2.12-0.11.0.1>bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
test
test2

enter image description here

I Find answers from @MiChael G Noll much helpful. I would advise following with respect to windows:

Start Zookeeper by [Remember to navigate to root of kafka-directory. The contents of root directory in windows is bin, config, libs, logs etc]:

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

Start kafka Server by .\bin\windows\kafka-server-start.bat .\config\server.properties

While you are doing all this, notice that for windows we navigated to .bin\windows from where we called the respective .bat files.

Similarly when you want to create topics or partitions remember that in your cmd terminal you are calling these .bat files from correct location[All while your root is kafka directory hence the use of .\bin The dot represents the root directory, in this root where kafka is stored].

Other relevant links and commands can be found here: https://www.javaer101.com/en/article/12057273.html

Also I would like to point out for beginners like me- the parallel between Linux and windows execution

In Linux to write message to console you call: kafka-console-producer.sh as follows: .sh is the extension for shell execution in linux

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

It's parallel in windows is observable through .bat extension, which is executable script on windows console[cmd]: kafka-console-producer.sh

.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test

Also notice the location of .bat and .sh in kafka. in windows it is located at bin\windows while in Linux it is available directly under bin for the kafka directory. Make sure to call accordingly !

Related