(I’m running on CentOS 5.8). I’ve been following the direction for a Clustered (Multiserver) Zookeeper Set-up, but getting an error when I try to start up my server. When I run the command as described in the documentation:
java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar:conf org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg
I get the error:
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
I have my files location as such and am running from the ~/zookeeper-3.4.6 directory:
~/zookeeper-3.4.6/zookeeper-3.4.6.jar
~/zookeeper-3.4.6/conf/zoo.cfg
~/zookeeper-3.4.6/data/myid
~/zookeeper-3.4.6/lib/log4j-1.2.16.jar
~/zookeeper-3.4.6/bin/zkServer.sh
Does anyone know why this error is happening? I don’t quite understand the arguments that are being passed, so it is hard for me to debug the path issue. As a side note, I’ve tried running ./zookeeper-3.4.6/bin/zkServer.sh start
, which did successfully work, but the documentation seems to indicate that command is meant for a single-node instance.
Edit:
I was able to make some progress by modifying the command and taking out the :conf
part, so now I’m running:
java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar: org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg
I get a new error, but this is progress…
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFacto
ry
at org.apache.zookeeper.server.quorum.QuorumPeerMain.<clinit>(QuorumPeer
Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
which corresponds to lines 63 and 64 from QuorumPeerMain
public class QuorumPeerMain {
private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerMain.class);
This miniature article explains how to resolve the following error:
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
This appears when we start the Apache Zookeeper (apache-zookeeper-3.5.6.tar.gz) installed on a multi-node cluster. Distributed systems/applications leverage the service offers by Apache Zookeeper to manage their synchronization, configuration service as well as naming registry.
Apache Zookeeper is a primary backbone for Hadoop, Kafka, HBase, Tableau, etc. The aforementioned error displays on the console when executing the script zkServer.sh with the input parameter start
available inside the bin directory. This happens due to the unavailability of the lib directory that holds the zookeeper-3.5.6.jar file.
Instead of extract/install apache-zookeeper-3.5.6.tar.gz
on each node in the cluster, we should proceed with apache-zookeeper-3.5.6-bin.tar.gz
, which has all the required jar files inside the lib directory. This binary can be downloaded from the following link found here.
Opinions expressed by DZone contributors are their own.
Log inSkip to main contentSkip to sidebar
Public signup for this instance is disabled. Our Jira Guidelines page explains how to get an account.
- Kafka
- KAFKA-1608
- XMLWordPrintableJSON
Details
-
Type:
Bug
-
Status:
Resolved -
Priority:
Minor
-
Resolution:
Fixed
-
Affects Version/s:
0.8.1.1
-
Fix Version/s:
None
-
Component/s:
core
Description
When trying to start zookeeper getting the following error in Windows
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
Fix for this is to edit windowskafka-run-class.bat
Change
set BASE_DIR=%CD%..
to
set BASE_DIR=%CD%….
Change
for %%i in (%BASE_DIR%corelib*.jar)
to
for %%i in (%BASE_DIR%libs*.jar)
Attachments
Activity
People
- Votes:
-
0
Vote for this issue
- Watchers:
-
2
Start watching this issue
Dates
- Created:
-
21/Aug/14 16:19
- Updated:
-
08/Sep/17 16:14
- Resolved:
-
08/Sep/17 16:14
Affected Version
0.14.2
Description
Ubuntu 18.04 following http://druid.io/docs/latest/tutorials/index.html
$ bin/supervise -c quickstart/tutorial/conf/tutorial-cluster.conf
[Sun Jun 2 00:52:18 2019] Running command[zk], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/zk.log]: bin/run-zk quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[coordinator], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/coordinator.log]: bin/run-druid coordinator quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[broker], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/broker.log]: bin/run-druid broker quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[router], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/router.log]: bin/run-druid router quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[historical], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/historical.log]: bin/run-druid historical quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[overlord], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/overlord.log]: bin/run-druid overlord quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Running command[middleManager], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/middleManager.log]: bin/run-druid middleManager quickstart/tutorial/conf
[Sun Jun 2 00:52:18 2019] Command[zk] exited (pid = 6876, exited = 1)
[Sun Jun 2 00:52:18 2019] Command[zk] failed, see logfile for more details: /home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/zk.log
[Sun Jun 2 00:52:21 2019] Running command[zk], logging to[/home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/zk.log]: bin/run-zk quickstart/tutorial/conf
[Sun Jun 2 00:52:21 2019] Command[zk] exited (pid = 7150, exited = 1)
[Sun Jun 2 00:52:21 2019] Command[zk] failed, see logfile for more details: /home/ubuntu/Downloads/apache-druid-0.14.2-incubating/var/sv/zk.log
^C[Sun Jun 2 00:52:22 2019] Sending signal[15] to command[middleManager] (timeout 10s).
[Sun Jun 2 00:52:22 2019] Command[middleManager] exited (pid = 6882, exited = 143)
[Sun Jun 2 00:52:22 2019] Sending signal[15] to command[overlord] (timeout 10s).
[Sun Jun 2 00:52:23 2019] Command[overlord] exited (pid = 6881, exited = 143)
[Sun Jun 2 00:52:23 2019] Sending signal[15] to command[coordinator] (timeout 10s).
[Sun Jun 2 00:52:23 2019] Sending signal[15] to command[broker] (timeout 10s).
[Sun Jun 2 00:52:23 2019] Sending signal[15] to command[router] (timeout 10s).
[Sun Jun 2 00:52:23 2019] Sending signal[15] to command[historical] (timeout 10s).
[Sun Jun 2 00:52:23 2019] Command[router] exited (pid = 6879, exited = 143)
[Sun Jun 2 00:52:23 2019] Command[historical] exited (pid = 6880, exited = 143)
[Sun Jun 2 00:52:23 2019] Command[coordinator] exited (pid = 6877, exited = 143)
[Sun Jun 2 00:52:23 2019] Command[broker] exited (pid = 6878, exited = 143)
[Sun Jun 2 00:52:23 2019] Exiting.
~/Downloads/apache-druid-0.14.2-incubating$ cat ~/Downloads/apache-druid-0.14.2-incubating/var/sv/zk.log
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
Looking through all the configs, and I found that zk
points to a folder:
$ cat quickstart/tutorial/conf/zk/zoo.cfg
#
# Server
#
tickTime=2000
dataDir=var/zk
clientPort=2182
initLimit=5
syncLimit=2
#
# Autopurge
#
autopurge.snapRetainCount=5
autopurge.purgeInterval=1
So I tried mkdir ~/Downloads/apache-druid-0.14.2-incubating/var/zk
, which worked.
(I’m running on CentOS 5.8). I’ve been following the direction for a Clustered (Multiserver) Zookeeper Set-up, but getting an error when I try to start up my server. When I run the command as described in the documentation:
java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar:conf org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg
I get the error:
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
I have my files location as such and am running from the ~/zookeeper-3.4.6 directory:
~/zookeeper-3.4.6/zookeeper-3.4.6.jar
~/zookeeper-3.4.6/conf/zoo.cfg
~/zookeeper-3.4.6/data/myid
~/zookeeper-3.4.6/lib/log4j-1.2.16.jar
~/zookeeper-3.4.6/bin/zkServer.sh
Does anyone know why this error is happening? I don’t quite understand the arguments that are being passed, so it is hard for me to debug the path issue. As a side note, I’ve tried running ./zookeeper-3.4.6/bin/zkServer.sh start
, which did successfully work, but the documentation seems to indicate that command is meant for a single-node instance.
Edit:
I was able to make some progress by modifying the command and taking out the :conf
part, so now I’m running:
java -cp zookeeper-3.4.6.jar:lib/log4j-1.2.16.jar: org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg
I get a new error, but this is progress…
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFacto
ry
at org.apache.zookeeper.server.quorum.QuorumPeerMain.<clinit>(QuorumPeer
Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
which corresponds to lines 63 and 64 from QuorumPeerMain
public class QuorumPeerMain {
private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerMain.class);
Я в основмном на idea работаю работадатели требуют kafka и zookeeper. Так в принципе. В целом с java ee работал.
Но именно с данной технологией сталкиваюсь в первые. Может я что то неправильно понял? я полностью следовал инструкции описанной https://habr.com/ru/post/496182/. Буду рад если поможете
Добавлено через 2 минуты
Здесь вот что показывает при вводе в командную строку без полного пути и с полным путем
Microsoft Windows [Version 10.0.19041.804]
(c) Корпорация Майкрософт (Microsoft Corporation), 2020. Все права защищены.
C:Usersuser>zkserver
C:Usersuser>C:Zookeeperzookeeper-3.6.1binzkserver
C:Usersuser>call «C:Program FilesJavajre1.8.0_281″binjava «-Dzookeeper.log.dir=C:Zookeeperzookeeper-3.6.1bin..logs» «-Dzookeeper.root.logger=INFO,CONSOLE» «-Dzookeeper.log.file=zookeeper-user-server-DESKTOP-DB4HRAC.log» «-XX:+HeapDumpOnOutOfMemoryError» «-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f» -cp «C:Zookeeperzookeeper-3.6.1bin..buildclasses;C:Zookeeperzookeeper-3.6.1bin..buildlib*;C:Zookeeperzookeeper-3.6.1bin..*;C:Zookeeperzookeeper-3.6.1bin..lib*;C:Zookeeperzookeeper-3.6.1bin..conf» org.apache.zookeeper.server.quorum.QuorumPeerMain «C:Zookeeperzookeeper-3.6.1bin..confzoo.cfg»
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
C:Usersuser>endlocal
C:Usersuser>
Добавлено через 1 минуту
Либо я взял не ту инструкцию https://habr.com/ru/post/496182/ и здесь описано совсем не те результаты, либо я что то делаю не то и получаю не те ожидаемые результы как в статье
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.
asked Jul 30 ’14 at 12:47
Pradeep SimhaPradeep Simha
16.5k16 gold badges53 silver badges104 bronze badges
1
Run these commands from your Kafka root folder:
cd binwindows
Then run Zookeper server:
zookeeper-server-start.bat ....configzookeeper.properties
Then run Kafka server:
kafka-server-start.bat ....configserver.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
answered Apr 30 ’15 at 0:17
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.
answered Jan 25 ’15 at 12:10
Salvador DaliSalvador Dali
188k133 gold badges652 silver badges717 bronze badges
1
I also got the same problem in Windows platform due to keeping the kafka_2.12-2.3.0 folder in the Program Files. I changed the Kafka directory from Program Files to C: drive root directory. It worked fine after executing the following commands:
First, go to the Kafka root folder:
cd C:kafka_2.12-2.3.0
Run Zookeeper server:
binwindowszookeeper-server-start.bat configzookeeper.properties
Then Run Kafka Server:
binwindowskafka-server-start.bat configserver.properties
answered Jul 16 ’19 at 13:48
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>binwindowszookeeper-server-start.bat configzookeeper.properties
juco
6,3113 gold badges23 silver badges41 bronze badges
answered Feb 10 ’15 at 16:45
1
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.
answered Apr 15 ’16 at 20:21
1
The solution for windows OS is to do the following:
- Download the binary version instead of the source version from the official website of Apache Kafka.
- Make sure the JAVA_HOME environment variable does not have a space in it (by default it is installed in Program files), follow the official installation documentation for this.
https://docs.oracle.com/cd/E39271_01/general.300/eid_getting_started/src/tgs_install_jdk.html. - Make sure the JRE path and KAFKA_HOME path do not have spaces in them as well.
- Run the zookeeper before starting Kafka.
answered Feb 16 ’19 at 13:50
1
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
Machavity♦
29.1k26 gold badges82 silver badges93 bronze badges
answered Feb 20 ’15 at 22:22
First Thing: Remove all blank space from the folder name.
Second Thing: Use Powershell
Wrong Path:
d:kafka node> .binwindowszookeeper-server-start.bat .configzookeeper.properties
Correct Path
d:kafka_node> .binwindowszookeeper-server-start.bat .configzookeeper.properties
Thanks & Regards
Jaiswar Vipin Kumar R.
answered Jun 17 ’20 at 12:08
1
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
pringi
1,4553 gold badges20 silver badges27 bronze badges
answered Jan 17 ’17 at 11:12
I had same problem used zookeeper-3.4.12.
bin directory do not has .bat files and windows directory.
Just exist .com and .sh files.
.com contain operation zookeeper execute.
As you can see, that has to find %JAVA%.
So I just set JAVA=[my java.exe path]. And it works.
answered Jan 29 ’19 at 5:36
I am using below mention command in windows environment.
Confluent_homebinwindows> zookeeper-server-start.bat ....etckafkazookeeper.properties
if still you are getting the same error, then please verify you folder structure, Is there any space between folder name if yes then replace with either «_» or removed completely.
I was also facing the same error.
answered Mar 28 ’20 at 22:14
Kafka docker for Windows OS
- Download the Zookeeper from page https://zookeeper.apache.org/releases.html (3.5.8)
- Download the Kafka from page https://kafka.apache.org/downloads (kafka_2.13-2.6.0)
Start Zookeeper
- Clone file
/conf/zoo_sample.cfg
to/conf/zoo.cfg
- Configure Zookeeper Admin (in
/conf/zoo.cfg
file) netty server port by adding this lineadmin.serverPort=8099
at the end of the zoo.cfg file. This is to avoid the App default port 8080 conflict later. - Run command to start
./zkServer.cmd
Stop Zookeeper
- Run command to stop:
./zkServer.cmd stop
Start Kafka
- Configure Kafka (in
/config/zookeeper.properties
file) with the Zookeeper admin port (e.g admin.serverPort=8099) - Run command to start
./kafka-server-start.bat ../../config/server.properties
Stop Kafka
- Run command to stop:
./kafka-server-stop.bat
Topics
- Run command to create a topic:
./kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_1
- Run command to list all topics:
./kafka-topics.bat --list --zookeeper localhost:2181
Test Topics
- Run command to verify if a topic was created:
./kafka-topics.bat --describe --topic test_1 --bootstrap-server localhost:9092
- Open terminal to create an event to the topic:
./kafka-console-producer.bat --topic test_1 --bootstrap-server localhost:9092
- Open terminal to read the event from the topic:
./kafka-console-consumer.bat --topic test_1 --from-beginning --bootstrap-server localhost:9092
Practical
- Write some events into the Topic (at
kafka-console-producer
terminal): This is an event - Will see the events printed out from reading by the consumer (at
kafka-console-consumer
terminal) => This is an event
Happy coding!
answered Dec 13 ’20 at 15:21
turongturong
9485 silver badges13 bronze badges
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.
answered May 10 ’18 at 7:38
Yes, I too faced the same problem and tried this way which was suggested in some comments above,
First I had my Kafka in C:Program Files
, Then I moved the kafka_2.11-2.1.0
folder to C:
directory and tried the following command and it worked
.binwindowskafka-server-start.bat configserver.properties
P.S — ran the zookeper server before starting kafka
Nick
119k20 gold badges44 silver badges75 bronze badges
answered Jan 30 ’19 at 3:46
mramsathmramsath
3223 silver badges7 bronze badges
Its bit weird. But replacing the root folder name to Kafka resolved my issue. It might help one or others.
answered May 19 ’20 at 11:29
3