zookeeper提供了客户端zkCli.sh脚本(window版本为zkCli.cmd)
通过zkCli.sh连接zookeeper服务
连接本机zookeeper服务,执行:
./zkCli.sh
连接远程zookeeper服务,跟上参数:
./zkCli.sh -server ip:port
在命令行输入:help
查看命令列表
[zk: localhost:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
stat path [watch]
set path data [version]
ls path [watch]
delquota [-n|-b] path
ls2 path [watch]
setAcl path acl
setquota -n|-b val path
history
redo cmdno
printwatches on|off
delete path [version]
sync path
listquota path
rmr path
get path [watch]
create [-s] [-e] path data acl
addauth scheme auth
quit
getAcl path
close
connect host:port
[zk: localhost:2181(CONNECTED) 1]
zkcli -server ip:port 连接指定的zookeeper服务器和端口
create -s -e path data [acl] 创建节点,-s表示顺序,-e表示临时,默认是持久节点,acl缺省表示不做任何权限限制
ls path [watch] 显示path下的节点,不递归显示,watch注册监听,命令行可忽视
ls2 path 显示当前节点下的节点和当前节点的属性信息
get path [watch] 获取path节点的属性信息和数据内容
set path data [version] 更新path节点的数据内容,version是做类似cas的功能的对应dataversion,命令行可忽略
delete path [version] 删除节点,不能递归删除,只能删除叶子节点
setacl path acl 设置path节点acl,例子(scheme:id:password=:perm)-(digest:example:sha-1(base64(pwd))=:cdrwa) create delete read write admin
getacl path 获取path节点的acl
stat path 查看path节点的属性信息
quit 退出客户端