Zookeeper simple command line operation

The first step is to connect to the client

zkCli.sh -server Slave1:2181`

I have configured the environment variables, you can use zkCli.sh directly, you need to enter the zookeeper bin for execution without configuration

`Insert picture description here

Create nodes:
There are four types of nodes: permanent nodes, temporary nodes, permanent serialized nodes, and temporary serialized nodes

create [-s] [-e] path data   # -s 序列化 -e 临时节点 path  创建路径  data 节点数据

Create a permanent serialization node
Insert picture description here

ls path  #显示path 下所有节点

Show all files in the root path
Insert picture description here

ls2 path # 查看path 	下所有znode,以及zonde的属性

Insert picture description here

get path  #获取path 对应Znode的数据和属性

Insert picture description here

Modify value

set path data  #修改值

Insert picture description here
Delete node

detele path # 删除节点

Insert picture description here
Recursively delete nodes

rmr path #循环删除节点
history #列出历史记录

Node attributes

dataVersion : data version number. Each time you perform a set operation on a node, the value of dataVersion will increase by 1 (even if the same data is set), which can effectively avoid the sequence problem when data is updated.
cversion : The version number of the child node. When the child nodes of znode change, the value of cversion will increase by 1.
aclVersion : ACL version number.
cZxid : The transaction id created by Znode.
mZxid : The transaction id of the Znode being modified, that is, the mZxid will be updated every time the znode is modified.
●For zk, every change will produce a unique transaction id, zxid (ZooKeeper TransactionId). Through zxid, you can determine the order of update operations. For example, if zxid1
● is less than zxid2, it means that the zxid1 operation occurred before zxid2, and zxid is unique for the entire zk,
ctime : the timestamp when the node was created
mtime : the latest node-the timestamp when the update occurred.
ephemeralowner : if this The node is a temporary node, and the ephemeralOwner value indicates the session id bound to the node. If it is not, the ephemeralOwner value is 0.

Guess you like

Origin blog.csdn.net/NewDay_/article/details/109016637