[zk: localhost:2181(CONNECTED) 15] create /persistent_node persistent_node_data Created /persistent_node [zk: localhost:2181(CONNECTED) 16] ls /persistent_node [] [zk: localhost:2181(CONNECTED) 17] get /persistent_node persistent_node_data
创建一个PERSISTENT_SEQUENTIAL
1 2 3 4
[zk: localhost:2181(CONNECTED) 18] create -s /persistent_node persistent_node_data Created /persistent_node0000000005 [zk: localhost:2181(CONNECTED) 19] get /persistent_node0000000005 persistent_node_data
创建一个EPHEMERAL_NODE
1 2 3 4
[zk: localhost:2181(CONNECTED) 20] create -e /ephemeral_node ephemeral_node_data Created /ephemeral_node [zk: localhost:2181(CONNECTED) 21] get /ephemeral_node ephemeral_node_data
创建一个EPHEMERAL_SEQUENTIAL
1 2 3 4
[zk: localhost:2181(CONNECTED) 22] create -s -e /ephemeral_node ephemeral_node_data Created /ephemeral_node0000000007 [zk: localhost:2181(CONNECTED) 23] get /ephemeral_node0000000007 ephemeral_node_data
delete(删除一个节点)
1 2 3
[zk: localhost:2181(CONNECTED) 27] delete /ephemeral_node0000000007 [zk: localhost:2181(CONNECTED) 28] ls /ephemeral_node0000000007 Node does not exist: /ephemeral_node0000000007
get (获得目录下的值)
参数
作用
-s
列出节点的状态信息
-w
设置观察数据变化的watcher
1 2
[zk: localhost:2181(CONNECTED) 10] get /2020-09-22 I am Tom