一、 端口
2181 zk对外服务端口
2888 Leader 监听端口
3888 Follower 监听端口
netstart -anop | grep 端口 查看端口连接状态
二、zkServer.sh
zkServer.sh start 打开本机zk服务
zkServer.sh stop 关闭本机zk服务
zkServer.sh status 查看本机zk服务状态
三、zkCli.sh -server IP:2181 以客户端形式连接zkserver, 进入交互式状态
ls path 累出path的子节点
create path 'data' 创建新的path并附带数据'data'
get path 获得path的详细信息
set path 'data' [version] 修改path的数据,指明version是为了防止发生冲突,当多个client对同一个path和version赋值时,只接受最先收到的那个
delete path [version] 删除节点,只能从叶子节点开始删除
rmr 递归删除节点及其子节点
quit 退出交互模式
四 node类型
临时节点 EPHEMERAL
The znode will be deleted upon the client's disconnect.
临时序列节点 EPHEMERAL_SEQUENTIAL
The znode will be deleted upon the client's disconnect, and its name will be appended with a monotonically increasing number.
持久节点 PERSISTENT
The znode will not be automatically deleted upon client's disconnect.
持久序列节点 PERSISTENT_SEQUENTIAL
The znode will not be automatically deleted upon client's disconnect, and its name will be appended with a monotonically increasing number.