Apache Kafka error on windows - Couldnot find or l

2019-01-17 18:26发布

问题:

I just downloaded Kafka 2.8.0 from Apache website, and I am trying to setup using the instructions given on the website. But when I try to start zookeper server, I am getting below error:

Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

My environment is Windows 7 64 bit. I tried to follow below e-mail chain: Apache Email Chain . But still it's having same issue. Can anyone guide me in this? As I am very new to this and couldn't find many information on Google/Apache Kafka email chain.

回答1:

Run these commands from your Kafka root folder:

cd bin/windows

Then run Zookeper server:

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

Then run Kafka server:

kafka-server-start.bat ../../config/server.properties


The gotcha here is to run the .bat files from the /bin/windows folder, so after you run your servers with the steps above and want to follow up with the tutorial, make sure you are running the correct batch files to create topics and whatnot, e.g.:

Create a topic:

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

List topics:

kafka-topics.bat --list --zookeeper localhost:2181



回答2:

This problem happened because you have downloaded wrong version of Kafka. On the official page

you have selected Source download. If you will download the binary, everything will work as expected.



回答3:

Had the same error message even though I had the correct Kafka download for my Scala version.

It ended up I was running the non-windows sh file (needed to run the bat in the windows sub-folder) and was running from within the bin folder instead of the root. Moving up to the root Kafka folder and running from there appears to have worked.

C:\kafka_2.10-0.8.2.0>bin\windows\zookeeper-server-start.bat config\zookeeper.properties



回答4:

Just download the binary and follow the steps mentioned in below link. http://kafka.apache.org/07/quickstart.html

if you are facing errors like

Error: Could not find or load main class org.apache.zookeeper.server.quorum.Quorumpeermain

copy zookeeper.properties from config folder to bin folder and bin/windows folder.

Now start the like
server : run zookeeper-server-start.bat zookeeper.properties

from bin or bin/windows(if you are in window machine). It should work.

If you are still facing problem, below link would be helpful http://blog.anilot.tk/2014/08/06/Set-Up-Kafka-On-Windows/

Now try staring the Kafka server.

use the below command if you are using windows: Goto bin/windows and then run kafka-server-start.bat ../../config/server.properties

if you are trying from shell prompt, goto bin and run below command

kafka-server-start.bat ../config/server.properties 

**Make sure server.properties is present in the config folder



回答5:

I'm running on OS X and I found that having spaces anywhere in the path leading to my Kafka base directory led to this exact error message. Renaming things without spaces solved the problem with no other fix.

As an example, my Kafka install was sitting at /Users/me/Kafka Demo/kafka_2.11-0.9.0.1 which caused that error when I tried to start Zookeeper. All I did was rename things as /Users/me/KafkaDemo/kafka_2.11-0.9.0.1 and everything worked fine.



回答6:

I downloaded latest stable Kafka from Apache and instruction mentioned by Matheus Felipe worked as expected.

I downloaded binary option - Scala 2.11 @ http://kafka.apache.org/downloads



回答7:

I used to meet the issue by running below cmd via git bash tool.

bin/zookeeper-server-start.sh config/zookeeper.properties

Solution: I switched to cygwin tool (http://cygwin.com/) to run the same cmd and I did not see the issue any more.