3

我像这样在我的cygwin控制台上启动了我的Zookeeper,它成功启动了 -

username@00542612 ~
$ zkServer.sh start
JMX enabled by default
Using config: C:\ApacheZookeeper\zookeeper-3.4.5\conf\zoo.cfg
Starting zookeeper ... STARTED

现在,在连接到 ZooKeeper 之后。我打开了一个新的 Cygwin 窗口,并发出以下命令

$ zkCli.sh

它将默认连接到运行在 localhost:2181 的 ZooKeeper 服务器,并打开 zk 控制台。这就是我在控制台上得到的。我相信直到现在一切都很好——

username@00542612 ~
$ zkCli.sh
Connecting to localhost:2181
2013-10-28 12:56:34,958 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2013-10-28 12:56:34,961 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=00542612.corp.host.com
2013-10-28 12:56:34,961 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.6.0_26
2013-10-28 12:56:34,962 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Sun Microsystems Inc.
2013-10-28 12:56:34,962 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=C:\Java\jdk1.6.0_26\jre
2013-10-28 12:56:34,963 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=C:\ApacheZookeeper\zookeeper-3.4.5\build\classes;C:\ApacheZookeeper\zookeeper-3.4.5\build\lib\*.jar;C:\ApacheZookeeper\zookeeper-3.4.5\lib\slf4j-log4j12-1.6.1.jar;C:\ApacheZookeeper\zookeeper-3.4.5\lib\slf4j-api-1.6.1.jar;C:\ApacheZookeeper\zookeeper-3.4.5\lib\netty-3.2.2.Final.jar;C:\ApacheZookeeper\zookeeper-3.4.5\lib\log4j-1.2.15.jar;C:\ApacheZookeeper\zookeeper-3.4.5\lib\jline-0.9.94.jar;C:\ApacheZookeeper\zookeeper-3.4.5\zookeeper-3.4.5.jar;C:\ApacheZookeeper\zookeeper-3.4.5\src\java\lib\*.jar;C:\ApacheZookeeper\zookeeper-3.4.5\conf;C;C:\Program Files (x86)\IBM\RationalSDLC\ClearQuest\cqjni.jar
2013-10-28 12:56:34,963 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=C:\Java\jdk1.6.0_26\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\cygwin\usr\local\bin;C:\cygwin\bin;C:\MinGW\msys\1.0\bin;C:\MinGW\bin;C:\Java\jdk1.6.0_26\bin;C:\cygwin\bin;C:\cygwin\etc\alternatives;C:\Program Files (x86)\DataStax Community\python;C:\Users\username\openssl\bin;C:\Python27;C:\Python27\Scripts;D:\app\username\product\11.1.0\db_1\bin;C:\apache-maven-3.0.4-bin\apache-maven-3.0.4\bin;C:\Program Files (x86)\IBM\RationalSDLC\Clearquest\cqcli\bin;C:\Perl64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Perl64\bin;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\RationalSDLC\common;D:\ede-5.1.1\apache-ant-1.7.1.2008.06.27\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\Common Files\Hitachi ID;C:\ApacheZookeeper\zookeeper-3.4.5\bin;%APPDATA%\Python\Scripts;.
2013-10-28 12:56:34,963 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=C:\cygwin\tmp\
2013-10-28 12:56:34,964 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2013-10-28 12:56:34,964 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Windows 7
2013-10-28 12:56:34,965 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2013-10-28 12:56:34,965 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=6.1
2013-10-28 12:56:34,965 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=username
2013-10-28 12:56:34,966 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=C:\Users\username
2013-10-28 12:56:34,966 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=C:\cygwin\home\username
2013-10-28 12:56:34,968 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@48b8f82d
Welcome to ZooKeeper!
2013-10-28 12:56:35,019 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@966] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (Unable to locate a login configuration)
JLine support is enabled
2013-10-28 12:56:35,021 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@849] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
2013-10-28 12:56:35,047 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1207] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x14200a378c30000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]

现在我试图ls /查看我一般有多少个节点,或者我也提供帮助,然后按 Enter 键,但我的控制台上没有发生任何事情 -

见下文 -

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /

写完后ls / 按回车键,我的控制台上什么也没有出现,同样help...这是我第一次与 Zookeeper 合作。有谁知道我在这里做错了什么?

更新:-

它在 Windows 命令提示符下工作正常,但在 CYGWIN 中不能正常工作。我不确定为什么它在 CYGWIN 中不能工作。

4

1 回答 1

4

我遇到过同样的问题。这就是我发现的。Zookeeper 使用 jline 为客户端做一些花哨的事情(例如历史浏览等)。我发现您可以通过添加来配置 jline

-Djline.terminal=jline.UnixTerminal

到你的 zkCli.sh 文件这是我的样子:

"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
 -Djline.terminal=jline.UnixTerminal \
 -cp "$CLASSPATH" $CLIENT_JVMFLAGS $JVMFLAGS \
 org.apache.zookeeper.ZooKeeperMain "$@"

如果我想要带有向上箭头的历史记录,我仍然可以在 Windows cmd 提示符下使用 .cmd 版本,但是由于我总是在 cygwin 中,这对我来说很好。

编辑:

您也可以简单地设置 CLIENT_JVMFLAGS。

此外,在阅读了 zookeeper 的代码后,从 lib 中删除 jline*.jar 应该可以工作。我没有尝试这个。

于 2014-03-17T18:01:23.087 回答