2

I have downloaded kafka_2.12-2.1.0 and placed in folder path "C:\kafka_2.12-2.1.0". For starting kafka zookeeper, I executed the below command in command prompt,

C:\kafka_2.12-2.1.0>bin\windows\zookeeper-server-start.bat config\zookeeper.properties

I am getting error message as below,

The syntax of the command is incorrect. The filename, directory name, or volume label syntax is incorrect.

I could not understand what I am doing wrong. Can someone please help. I am successfully able to start zookeeper and kafka server in Linux "bin/zookeeper-server-start.sh config/zookeeper.properties"

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • You can follow the answer at https://stackoverflow.com/questions/25037263/apache-kafka-error-on-windows-couldnot-find-or-load-main-class-quorumpeermain/65277228#65277228 – turong Dec 20 '20 at 05:59

1 Answers1

3

First of all, don't forget that you're in a windows operating system so don't forget the dot . before the path .\bin\...

Zookeeper Installation Locate your Zookeeper config directory. For example C:\zookeeper-3.4.7\conf.

Locate .cfg file and Copy and Rename zoo_sample.cfg to zoo.cfg in C:\Tools\zookeeper-3.4.9\conf

Open it with any text editor like Notepad++

Find and edit dataDir=/tmp/zookeeper to :\zookeeper-3.4.7\data

In addition, add an entry in the System Environment Variables as you did for Java. this means something like this

Add ZOOKEEPER_HOME = C:\zookeeper-3.4.7 to the System Variables.

add ;%ZOOKEEPER_HOME%\bin;

Run Zookeeper by opening a new cmd and type : zkserver.

KafkaServer

Running a Kafka Server type

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

Create Topic

in order to create topics now you should do this:

  • Now create a topic with the name “test” and a replication factor of 1, as we have only one Kafka server running. If you have a cluster with more than one Kafka server running, you can increase the replication-factor accordingly, which will increase the data availability and act like a fault-tolerant system.

  • Open a new command prompt in the location C:\kafka_2.12-2.1.0\bin\windows.

  • Type the following command and hit Enter:

kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Creating a simple Producer and Consumer to Test

Open a new command prompt in the location C:\kafka_2.12-2.1.0\bin\windows and type this for the producer:

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

Again open a new command prompt in the same location and type:

kafka-console-consumer.bat --zookeeper localhost:2181 --topic test

Take a look at this post you will find it useful

Panagiotis Drakatos
  • 2,851
  • 4
  • 31
  • 43
  • Thanks for the response.. I found the actual problem here. The issue is not because of the command that I run in command prompt. But it is the convention of referring current directory in .bat file. In .bat file, the current directory is referred as %~dp0 instead of %CD%. And also the file path is referred in Linux file convension like "../config/zookeeper.properties" instead of "%CD%\config\zookeeper.properties". I modified them and executed the command in prompt. But the hard thing is, there are many places I need to change the directory path. Better I will download apache zookeeper and try. – Saravanan Ponnaiah Feb 06 '19 at 09:56