启动 Zookeeper 集群.错误:无法找到或加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain [英] Starting Zookeeper Cluster. Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

查看:181
本文介绍了启动 Zookeeper 集群.错误:无法找到或加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我在 CentOS 5.8 上运行).我一直在遵循 集群(多服务器)Zookeeper 设置的方向,但在我尝试启动服务器时出现错误.当我按照文档中的描述运行命令时:

(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 

我收到错误:

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

我有我的文件位置,并且从 ~/zookeeper-3.4.6 目录运行:

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

有谁知道为什么会发生这个错误?我不太明白传递的参数,所以我很难调试路径问题.作为旁注,我尝试运行 ./zookeeper-3.4.6/bin/zkServer.sh start,它确实成功运行,但文档似乎表明该命令是针对单个-节点实例.

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.

编辑:

我可以通过修改命令并删除 :conf \ 部分来取得一些进展,所以现在我正在运行:

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

对应于 QuorumPeerMain 的第 63 和 64 行

which corresponds to lines 63 and 64 from QuorumPeerMain

public class QuorumPeerMain {
    private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerMain.class);

推荐答案

您应该能够运行 zkServer.sh 来获得集群设置.它将使用您手动提供的相同 conf/zoo.cfg,其中将包含集群端点.

You should be able to run zkServer.sh to get a clustered setup. It will use the same conf/zoo.cfg that you are providing manually, which will contain the cluster endpoints.

检查类路径中缺少什么(并查看正确的 java 命令)的最佳方法是运行您说对您有用的 zkServer.sh.

The best way to check what you are missing from your classpath (and see the proper java command) is to run the zkServer.sh you said worked for you.

当它启动时,检查实际使用的命令如下:

When it starts up, check the actual command used like this:

ps -ef | grep zookeeper

这篇关于启动 Zookeeper 集群.错误:无法找到或加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆