zookeeper basic operations

zk start after installation is complete, go to the bin directory. Find zkCli.sh

Using the default connection command zkCli.sh native conf zoo.cfg zk default port configuration.

You can also use ./zkCli.sh -server ip address: port number specified zk server connection

Or using zk visualization tools zktools, ZooInspector connected zk.

The following describes the use of command-line operation zk:

 

 

 

 

zk data has been stored in the form of nodes, child nodes of nodes allowed. So zk data model tree

  zk divided into four kinds of nodes:

  • Persistent node ( PERSISTENT ). After nodes creation has been present on the ZooKeeper server, unless the operation to remove the active node.

  • Persistent order of nodes ( PERSISTENT_SEQUENTIAL ). Compared lasting node, its new characteristics of the order, each parent will maintain an order for its first-level child node, used to record the sequence of nodes created for each child. When you create a node, automatically adds a numeric suffix, as the new node name, the upper limit of the number suffix is shaping maximum.

  • Temporary node ( EPEMERAL ). Lifecycle temporary node with the client session binding, the client fails, the node will be automatically cleaned up. Meanwhile, ZooKeeper can not be based on the provisions of the temporary node to create a child node, the node only as a temporary leaf node.

  • Temporal order node ( EPEMERAL_SEQUENTIAL ). On the basis of the temporary node adds sequencing features.

  Use the command ls / view all the nodes

Creating nodes

  Use the command create [-s] [-e] [-c] [-t ttl] path [data] [acl] -c (after the new 3.5 version, it can not) create a permanent node -e create temporary node - s create a temporary sequential node node does not have a progressive sequential and child nodes when the session ends, the temporary node automatically deleted

Delete Node

  Use command deleteall path (rmr path command deprecated in this version 3.5) or delete [-v version] path 

Gets node

  Use the command get [-s] [-w] path -w indicate watch monitor events

Setting node data

  Use the command set [-s] [-v version] path data

Setting node listens

  Use the command stat [-w] path or ls2 path [watch], use the command line to set the listener can only take effect once

Gain control ACL

  Use the command getAcl [-s] path

Setting ACL control

  Use command setAcl [-s] [-v version] [-R] path acl

Dynamic setting zk cluster (3.5 new)

  使用命令  reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]

  Zk still solve the problems of expansion, each server needs to be reconfigured zoo.cfg file and restart zk problems

 

  

 

Guess you like

Origin www.cnblogs.com/happily-ye/p/12498421.html