Zookeeper cli没有启动

时间:2017-07-26 11:57:43

标签: java apache-zookeeper

我使用以下软件包在suse上安装了zookeeper v 3.4.9:

zkCli.sh -server 127.0.0.1:2181
Error: Could not find or load main class org.apache.zookeeper.ZooKeeperMain

启动服务器工作得很好,需要连接到它的各种应用程序似乎能够这样做,但是当我尝试启动客户端时出现了一个奇怪的错误:

opts = prompt("Do you want to TALK or LOOK?").toUpperCase();

switch(opts) {
  case "TALK":
    mes = "Is anyone in charge here?";
    speech = "Our leader is in the big building.";
    talkNot();
    break;
  case "LOOK":
    window.alert("The buildings are quite simple, and the doorways are much shorter than you. You notice, however, that there is a very tall, thin building at the end of the street.");
    break;
  default:
    window.alert("That's not an option.");
}

我试过在互联网上搜索,但我想出的唯一答案是设置env变量$ CLASSPATH。我尝试查看服务启动脚本在内部使用的类路径,并将$ CLASSPATH设置为该但没有结果。

我正在运行openjvm v 1.8.0_121

3 个答案:

答案 0 :(得分:0)

您是在尝试使用Unix还是Windows?

我不认为,你需要“-server 127.0.0.1:2181”

只需运行zkCli.sh或zkCli.cmd

答案 1 :(得分:0)

那是一个类路径问题。 zkCli.sh脚本正在尝试启动一个Java应用程序,其中的主要类是ZooKeeperMain。但是,Java无法找到ZooKeeperMain类文件,因为传递给java的类路径不包含包含ZooKeeperMain类的jar文件。

通常,ZooKeeperMain.class文件包含在jar文件中,类似于$ZOOKEEPER_HOME/zookeeper-3.4.13.jar

您可以尝试在脚本试图启动ZooKeeperMain之前修改zkCli.sh脚本以打印出类路径。类路径应包含包含ZooKeeperMain类的jar。

在Windows 10计算机上,我的类路径如下:

/c/Program Files (x86)/Zookeeper/bin/../build/classes:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-log4j12-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/slf4j-api-1.7.25.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/netty-3.10.6.Final.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/log4j-1.2.17.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/jline-0.9.94.jar:/c/Program Files (x86)/Zookeeper/bin/../lib/audience-annotations-0.5.0.jar:/c/Program Files (x86)/Zookeeper/bin/../zookeeper-3.4.12.jar:/c/Program Files (x86)/Zookeeper/bin/../conf:

在Windows 10计算机上从Git Bash for Windows启动zkCli.sh时,遇到了与您类似的错误。我的问题是因为Git Bash在类路径中处理通配符的方式。最初,我在类路径中有一些*.jar条目已删除,以便启动zkCli.sh。

答案 2 :(得分:0)

我今天在Ubuntu 18.04上遇到了这个问题。在zookeper official download page上,一旦遵循给定的镜像链接并选择了稳定版本,他就可以看到2个文件。在我的情况下,这些是:

  • apache-zookeeper-3.5.5-bin.tar.gz
  • apache-zookeeper-3.5.5.tar.gz

我选择了apache-zookeeper-3.5.5.tar.gz,发现了同样的问题。试图按照@Jonathan的建议打印CLASSPATH,但它打印的路径不同,但问题是存档文件不包含Zookeper jar,可能是希望用户将软件包打包到jar我自己,因为我可以在该存档文件中找到源代码。

下载更大的apache-zookeeper-3.5.5-bin.tar.gz归档文件,提取并运行./zkCli.sh十分顺利,因为它具有一切必要的功能,因此,如果遇到相同的问题,请尝试一下,看看是否能解决您的问题。