我刚刚打开CDH 5.4并安装了zookeeper。我以前成功使用过zkCli很多次。这次命令行启动停止,然后出现提示

Welcome to ZooKeeper!
JLine support is disabled
2015-05-04 18:18:33,936 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2015-05-04 18:18:33,952 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2015-05-04 18:18:33,985 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x34d12349d0a15cf, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

我知道通常的打印输出是
启用JLine支持

那是什么让它卡住了?我看不到任何方法可以更改Cloudera Manager配置页面。

最佳答案

简短

Cloudera在多个地方破坏了zookeeper 3.4.5-cdh5.4.0。服务正在运行,但CLI无效。除了回滚之外,没有其他解决方法。

LONG

为此分配一个赏金;-)。我也踩过这个地雷,很生气地找到原因:

Zookeeper在JLine期间检查ZooKeeperMain.run()。有一个try-catch块,它加载类的数量。类加载期间的任何异常会使整个块失效,并且JLine支持被报告为已禁用。

但是这就是为什么CDH 5.4.0会发生这种情况:

  • 当前的开源Zookeeper-3.4.6jline-0.9.94兼容。没有这样的问题。
  • CDH 5.4中,Cloudera应用了以下修补程序:
  • 
    roman@node4:$ diff zookeeper-3.4.5-cdh5.3.3/src/java/main/org/apache/zookeeper/ZooKeeperMain.java zookeeper-3.4.5-cdh5.4.0/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
    
    305,306c305,306
    <                 Class consoleC = Class.forName("jline.ConsoleReader");
    <                 Class completorC =
    ---
    >                 Class consoleC = Class.forName("jline.ConsoleReader");
    >                 Class completorC =
    316,317c316,317
    <                 Method addCompletor = consoleC.getMethod("addCompletor",
    <                         Class.forName("jline.Completor"));
    ---
    >                 Method addCompletor = consoleC.getMethod("addCompleter",
    >                         Class.forName("jline.console.completer.Completer"));
    
    
    1. CDH 5.4 uses jline-2.11.jar for ZooKeeper and it has no jline.ConsoleReader class (from 2.11 it is jline.console.ConsoleReader).

    2. Jline 0.9.94 in turn has no jline.console.completer.Completer.

    So there is incompatibility with any existing JLine. Any Cloudera CDH 5.4 user can run zookeeper-client on his/her cluster and find it does not work.

    Open source zookeeper-3.4.6 depends on jline-0.9.94 which has no such patches. Don't know why Cloudera engineers have done such a mine.

    I see no clean way to fix it with 3.4.5-cdh5.4.0. I stayed with 3.4.5-cdh5.3.3 dependency where I need CLI and have production clusters.

    1. It seemed to me both jline-0.9.94.jar and jline.2.11.jar in classpath for zookeeper will fix the problem. But just have found Cloudera made another 'fix' in ZK for CDH 5.4.0, they have renamed org.apache.zookeeper.JLineZNodeCompletor class to org.apache.zookeeper.JLineZNodeCompleter.

    But here is the code from ZooKeeperMain.java

    Class<?> completorC =                    Class.forName("org.apache.zookeeper.JLineZNodeCompletor");
    

    当然,这实际上意味着不可能以CDH 5.4.0的正确方式启动ZK CLI。辛苦了:-(

    09-26 22:10