我刚刚打开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.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。辛苦了:-(