1.进入zookeeper环境
[root@master ~]# zkCli.sh
2.创建节点
create 不加参数 创建节点
[zk: localhost:2181(CONNECTED) 34] create /seq
Created /seq
-e 参数 创建临时节点(退出后过一会默认删除)临时节点不能存在子节点
[zk: localhost:2181(CONNECTED) 0] create -e /temp temp
[zk: localhost:2181(CONNECTED) 2] ls /
[admin, brokers, cluster, config, consumers, controller_epoch, feature, isr_change_notification, latest_producer_id_block, log_dir_event_notification, temp, zookeeper]
[zk: localhost:2181(CONNECTED) 1] ls /temp
[]
-s参数会默认递增id创建子节点
[zk: localhost:2181(CONNECTED) 35] create -s /seq/ 1
Created /seq/0000000000
[zk: localhost:2181(CONNECTED) 36] create -s /seq/ 1
Created /seq/0000000001
[zk: localhost:2181(CONNECTED) 37] create -s /seq/ 1
Created /seq/0000000002
[zk: localhost:2181(CONNECTED) 38] ls /seq
[0000000000, 0000000001, 0000000002]
3.删除临时节点
[zk: localhost:2181(CONNECTED) 7] ls /locks
[zk: localhost:2181(CONNECTED) 8] delete /locks/000000002