我刚刚启动了 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 管理器配置页面。
最佳答案
免责声明:请注意答案来自 2015 年。它可能不再相关,但可能有助于历史目的,并对类似的“现代”案例有所启发。
简短
Cloudera 在多个地方损坏了 zookeeper 3.4.5-cdh5.4.0
。服务正在运行,但 CLI 已死。除了回滚之外没有解决方法。
长
为此分配赏金 ;-)。我也踩过这个地雷,气得找原因:
Zookeeper 在 ZooKeeperMain.run()
期间检查 JLine
。有 try-catch block 加载类的数量。类加载期间的任何异常都会导致整个 block 失败,并且报告 JLine 支持已被禁用。
但这就是 CDH 5.4.0
发生这种情况的原因:
当前的开源
Zookeeper-3.4.6
适用于jline-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"));
CDH 5.4 uses
jline-2.11.jar
for ZooKeeper and it has nojline.ConsoleReader
class (from2.11
it isjline.console.ConsoleReader
).Jline 0.9.94
in turn has nojline.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.
- It seemed to me both
jline-0.9.94.jar
andjline.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 renamedorg.apache.zookeeper.JLineZNodeCompletor
class toorg.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。糟糕的工作。 :-(
关于java - zookeeper 客户端不向 CLI 提供 "jline support is disabled"消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30043897/