Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic Zookeeper client commands and how to use them?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you what Zookeeper client basic commands have and how to use the relevant knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

ZooKeeper is a reliable coordination system for large-scale distributed systems, which provides functions such as configuration maintenance, name service, distributed synchronization, group service and so on.

The zookeeper command is used to perform operations on the zookeeper service.

First execute the command, open a new session session, and enter the terminal.

$sh zkCli.sh

Ls command

The ls command is used to view a list of directories under a path.

Format:

Ls path

Path: represents the path. The following example views the / runoob node:

$ls / runoob

Ls2 command

The ls2 command is used to view a list of directories under a path, and it lists more details than the ls command.

Format:

Ls2 path

Path: represents the path. The following example views the / runoob node:

$ls2 / runoob

Get command

The get command is used to get node data and status information.

Format:

Get path [watch]

Path: represents the path. [watch]: listen for events on the node. The following example shows that two terminals are opened at the same time.

Terminal one:

$get / runoob watch

Modify this node in Terminal 2:

$set / runoob 1

Terminal one automatically displays NodeDataChanged events:

Stat command

The stat command is used to view node status information.

Format:

Stat path [watch]

Path: represents the path. [watch]: listen for events on the node. The following example views the status of the / runoob node:

$stat / runoob

Create command

The create command is used to create nodes and assign values.

Format:

Create [- s] [- e] path data acl [- s] [- e]:-s and-e are optional,-s represents sequential nodes,-e represents temporary nodes, note that-s and-e can be used at the same time, and temporary nodes can no longer create child nodes. Path: specify the path where you want to create the node, such as / runoob. Data: the data to be stored on this node. Path: the access permission is related. The default is world, which means that it can be accessed all over the world.

The following example adds a temporary sequence node:

$create-s-e / runoob 0

The nodes created are both ordered and temporary.

Set command

The set command is used to modify the data stored by the node.

Format:

Set path data [version] path: node path. Data: the data to be stored. [version]: optional, version number (can be used as an optimistic lock).

The following example enables two terminals, or you can operate on the same terminal:

$get / runoob

As can be seen in the following figure, only the correct version number can be set successfully:

$set / runoob 0 1$ set / runoob 0 2$ set / runoob 0 10$ set / runoob 0 6

Delete command

The delete command is used to delete a node.

Format:

Delete path [version] path: node path. [version]: optional, version number (same as set command).

The following example deletes the child nodes of the / runoob node:

$ls / runoob$ delete / runoob/child$ get / runoob/child

These are all the contents of this article entitled "what are the basic Zookeeper client commands and how to use them?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report