启动服务器:
zkServer.sh start
启动客户端:
zkCli.sh -server 127.0.0.1:2181
ls / 显示
create /zk_test my_data 新建; create -e /zk_test my_data 是创建临时节点
-s 创建顺序节点,利用这个特性可以实现分布式锁:create -e -s /worker/lock xx
set /zk_test new_data 设置
get /zk_test 获取
stat /zhang 查看属性
ls /zhang watch
当在/zhang目录下面创建子节点时,客户端会收到通知
get /zhang watch
当/zhang的值发生变化时,客户端会收到通知
stat /zhang watch
当/zhang的值发生变化时,客户端会收到通知