下载直接到zk的官网(zookeeper.apache.org)即可,点击右边的Releases,在Download下再点Download进入镜像下载页面,在给出的链接列表里选择一个镜像地址,进去后选择版本(这里最新的是3.4.14)下载压缩包。
解压到本地(这里是D盘)后,需要修改下配置文件名,进入conf目录,将zoo_sample.cfg改为zoo.cfg。如果仅将zk作为单点来用,那么进入bin目录双击zkServer.cmd启动服务端,出现命令行窗口,再双击zkCli.cmd启动客户端,这时就可以开始在客户端敲命令了:
[zk: localhost:2181(CONNECTED) 2] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 3] create /zk hello,world!
Created /zk
[zk: localhost:2181(CONNECTED) 4] ls /
[zk, zookeeper]
[zk: localhost:2181(CONNECTED) 5] get /zk
hello,world!
cZxid = 0x2
ctime = Tue Sep 11 11:22:48 CST 2018
mZxid = 0x2
mtime = Tue Sep 11 11:22:48 CST 2018
pZxid = 0x2
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0