(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);
7条答案
按热度按时间zazmityj1#
我得到了
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
,因为我下载了apache-zookeeper-X.X.X.tar.gz文件,而不是apache-zookeeper-X.X.X.bin.tar.gz文件。下载、解压缩和使用bin.tar文件为我修复了它。您还可以从apache-zookeeper-X.X.X.tar.gz文件构建二进制文件;见@vincent的回答。
oknwwptz2#
当你下载并使用apache-zookeeper-X.X.X.tar.gz时会发生这种情况,你应该使用apache-zookeeper-X.X.X-bin. tar.gz。这肯定会解决这个问题
sd2nnvve3#
这个问题可以通过解衡apache-zookeeper-3.5.6-bin.tar.gz来解决。最初,我在解衡/安装apache-zookeeper-3.5.6.tar.gz并执行/bin/ www.example.com start时遇到了同样的错误zkServer.sh
请确保您已下载apache-zookeeper-3.5.6-bin.tar.gz
pb3s4cty4#
我得到了同样的错误。我通过检查README.mdapache-zookeeper-[version].tar.gz中的www.example.com文件解决了这个错误。只需键入:
然后启动Zookeeper。2你也会解决这个错误。
68de4m5k5#
您应该可以执行zkServer.sh来取得丛集设定。它会使用您手动提供的相同conf/zoo.cfg,其中包含丛集端点。
检查类路径中缺少的内容(并查看正确的java命令)的最好方法是运行zkServer.sh您说对您有用的www.example.com。
启动时,检查实际使用的命令,如下所示:
qjp7pelc6#
当我尝试在Windows上运行Apache Zookeper v3.5.5时,也会遇到此错误:
错误:无法找到或加载主类org.apache.zookeeper.server.quorum.QuorumPeerMain
正如@Onnonymous所说,我通过下载.bin.tar.gz(here)而不是.tar.gz版本来完成我的问题。
yzuktlbb7#
我使用的是apache-zookeeper-3.8.0-bin.tar.gz(Ubuntu 20.04)这包含成功启动zookeeper进程所需的所有文件。在zoo.cfg文件中指定其他节点并启动zookeeper会自动添加其他节点并启动选举进程。
数字海洋在这里有一个很好的设置指南setup zookeeper cluster
以下是zoo.cfg文件以供参考