在学习zookeeper 的时候会用到zkCli.sh 对节点进行操作,此处总结下zkCli.SH的一些常用命令用法。
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
查看节点命令 ls /path
[zk: localhost:2181(CONNECTED) 1] ls /
创建节点
[zk: localhost:2181(CONNECTED) 2] create /test “test”
查看节点数据
[zk: localhost:2181(CONNECTED) 4] get /test
设置节点数据
[zk: localhost:2181(CONNECTED) 7] set /test “111111”
删除节点
[zk: localhost:2181(CONNECTED) 9] delete /test