Chapter 2 zookeeper installation (windows)

1. Environment

  JDK 1.8

  zookeeper-3.4.12 Log in to the official website to find the corresponding download address  http://mirrors.shu.edu.cn/apache/zookeeper/zookeeper-3.4.12/

2. Installation (stand-alone mode)

  1) Unzip the downloaded gz package to the corresponding directory.

  2) There are three main ways to start zookeeper: stand-alone mode, cluster mode and pseudo-distributed cluster (one machine starts multiple zookeepers). Let's demonstrate the stand-alone mode first.

  3) Copy D:\zookeeper-3.4.12\conf\zoo_sample.cfg to D:\zookeeper-3.4.12\conf\zoo.cfg and modify it as follows

  

  4) Find the installed bin directory such as D:\zookeeper-3.4.12\bin

  

  5) Access -server through zkCli.cmd and enter ip: port for the connection command 

  

3. Common commands

  After connecting to the console, you can use the following common commands to operate.

  1) h(help): View help

  2) ls: List the child node information under a node, ls2: List the child nodes of the current node, and list the node status at the same time.

  3) create: create node
  -s: sequential node
  -e: temporary node (delete the node after the session exits)
  such as: create /data "myData"

  

  4) get: Get the data content stored by the current node,
  such as: get /data

  

  5) stat: View the status information of the node

  czxid: transaction ID when the node was created
  ctime: creation time
  mzxid: last updated transaction ID
  mtime: modification time
  pzxid: last updated transaction ID of the child node list
  cversion: child node version number
  dataversion: data version number
  aclversion : permission version number
  ephemeralOwner: used for temporary nodes, representing the transaction ID of the temporary node, if it is a persistent node, it is 0
  dataLength: the length of the data stored by the node
  numChildren: the number of child nodes of the current node

  6) set: modify node data, can carry version number
  such as: set /data "modifyData"

  

  7) delete: delete a node, only nodes without child nodes can be deleted,
  such as: delete /data

  8) rmr: recursively delete nodes (including child nodes)
  such as: rmr /data

  9) setquota: set quota

  Limit values ​​for nodes, such as limiting the number of child nodes and the length of node data (when the created node exceeds the quota, zookeeper will not throw an exception, and will record warning information in zookeeper.out)
  -n: limit the number of child nodes
  -b : Limit the length of the value

  10) listquota: View the quota and the quota status of the node. delquota: delete quota.

4. Pseudo-distributed

  The zookeeper cluster is generally an odd number, and more than half of the master elections are usually passed.

  1) Copy three copies of the zookeeper application 

  2) Create three zk directories for storing myid files (marking the zookeeper application id) and enter 1, 2, and 3 in the myid file respectively

   

 

  3) Modify the configuration files in turn D:\zookeeper-3.4.12 - 1\conf, D:\zookeeper-3.4.12 - 2\conf, D:\zookeeper-3.4.12 - 3\conf 

   

  server.X=ip:A:B Explain here, X is the value in the myid file under the corresponding dataDir, A is the leader communication port in the zk and zk clusters, and B is the leader election communication window after the leader hangs up.

  4) Enter the bing directory of zk respectively, start three zk services, the method is the same as before, enter cmd to execute zkServer.cmd. An error will be reported, because the election of zk's master requires more than half of the nodes to pass.

   

  

  5) After all three are started, the exception disappears. Start the cli for operation verification, and we connect to port 2181 for verification.

  

  

V. Summary

  The installation of zookeeper and the simplicity and practicality of the console are briefly introduced. The content of zookeeper is much more than that, such as the knowledge of ACL-related permissions, leader election protocol, etc., and you can study in depth if you are interested. Generally speaking, it is the znode node that we deal with the most.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325791060&siteId=291194637