Could not start zookeeper for kafka on windows
Asked Answered
H

7

5

I have the following folder structure:

enter image description here

from C:\Program Files\kafka\kafka_2.11-0.11.0.0 frolder I try to execute following command:

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

and it reponds with following message:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

I tried to use several another variants but I still see errors:

C:\Program Files\kafka\kafka_2.11-0.11.0.0>bin\windows\zookeeper-server-start.bat
USAGE: bin\windows\zookeeper-server-start.bat zookeeper.properties

C:\Program Files\kafka\kafka_2.11-0.11.0.0>bin\windows\zookeeper-server-start.bat C:\Program Files\kafka\kafka_2.11-0.11.0.0\config\zookeeper.properties
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\kafka\kafka_2.11-0.11.0.0>bin\windows\zookeeper-server-start.bat 'C:\Program Files\kafka\kafka_2.11-0.11.0.0\config\zookeeper.properties'
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

What do I wrong?

Heterosporous answered 1/9, 2017 at 13:35 Comment(1)
FYI, There is an open JIRA on the Kafka project regarding this issue: issues.apache.org/jira/browse/KAFKA-4860. It should be fixed in one of the upcoming releases.Roney
S
6

You can resolve this issue by declaring path in environment variable for your kafka folder like this C:\kafka_2.12-2.8.0\bin\windows and after that open a fresh terminal and try to run the same command and it will work hopefully.

Squally answered 7/8, 2021 at 13:8 Comment(1)
your answer helped me I was running this command from bin directory but when I used it from windows it worked. Thank You Command : : zookeeper-server-start.bat ..\..\config\zookeeper.propertiesHibbler
C
1

Paths containing spaces need to be enquoted (i.e. "C:\Program Files\kafka\" instead of C:\Program Files\kafka\).

The simplest solution would be to move your kafka folder to a path which contains no spaces, such as C:\kafka, and adjust the configuration file accordingly.

Another option would be to edit your configuration files (and possibly the batch files as well) and to enquote the paths which contain spaces.

A third, unrecommended option would be to use the 8.3 path syntax, which means editing the config and batch files to use C:\Progra~1\kafka instead of C:\Program Files\kafka

Careworn answered 1/9, 2017 at 13:43 Comment(7)
I already inside Program Files directory. What should I quote?Heterosporous
What should I do exactly ?Heterosporous
The paths inside zookeeper.properties. But I recommend you start by moving the folders to a spaceless path, which would get you an up and running system quickly, and only then tackle the issue of running it from Program Files.Careworn
dataDir=/tmp/zookeeper clientPort=2181 maxClientCnxns=0Heterosporous
@ M.A. Hanin I don't see paths hereHeterosporous
Edit dataDir=/tmp/zookeeper to C:\zookeeper-3.4.9\data(set it as per your requirement)Wilheminawilhide
@M.A. Hanin Your suggestion of using quoted path is not working. It is giving this error: [2017-09-02 01:19:53,059] FATAL (kafka.Kafka$) java.nio.file.InvalidPathException: Illegal char <"> at index 0: "C:kafka_2.11-0.11.0.0kafka-logs"\meta.properties.tmp at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)Wilheminawilhide
S
1

You can try this:

bin\windows\zookeeper-server-start.bat .. \ ..\config\zookeeper.properties
Skardol answered 13/3, 2018 at 14:2 Comment(0)
C
1

I got the same issue when I want to run server. Actually this had happened due to the long path where you had saved your Kafka Folder. Previously I had saved my Kafka folder in User's Directory ("C:\Users\xxxx\xxxx\kafka_2.13-2.8.0"). So after changing path of my Kafka folder to ("C:") it got solved.

Coot answered 24/4, 2021 at 11:23 Comment(0)
A
1

The path is too long, move the folder to "C:\kafka_2.11-0.11.0.0" and then run the command again, this should work.

Apostate answered 28/10, 2022 at 14:28 Comment(0)
B
0

Commands to follow for kafka and zookeeper set up:

  1. Download kafka from https://dlcdn.apache.org/kafka/3.5.0/kafka_2.13-3.5.0.tgz And store into D:\Learning\kafka then unzip it there only.

  2. Set path in environment veriable as D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows

  3. Start the kafka – Open cmd in D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows> and run

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

Open another cmd in D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows> and run

kafka-server-start.bat ..\..\config\server.properties
  1. Create the topic to store your events -
    Open another cmd in D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows> and run

    kafka-topics.bat --create --topic quickstart-events --bootstrap-server localhost:9092 kafka-topics.bat --describe --topic quickstart-events --bootstrap-server localhost:9092

  2. Write some topics into the topic – Open another cmd in D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows> and run

    kafka-console-producer.bat --topic quickstart-events --bootstrap-server localhost:9092 This is my first event This is my second event

  3. Read the events – Open another cmd in D:\Learning\kafka\kafka_2.13-3.5.0\bin\windows> and run

    kafka-console-consumer.bat --topic quickstart-events --from-beginning --bootstrap-server localhost:9092

Blouin answered 4/7, 2023 at 11:49 Comment(0)
S
0

Edit the server.properties file

log dirs = /temp/kafka-logs

To

log dirs = C:/kafka/kafka_2.13/kafka-logs

(the above is the path file in my case)

Also, edit the zookeeper.properties

dataDir = C:/kafka/kafka_2.13/zookeeper-data

Basically, change the property files with your actual file location and it will clear all the issues.

Sitnik answered 30/1 at 14:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.