In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use the Zookeeper data model", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the Zookeeper data model" this article.
As the underlying coordination service of distributed system, Zookeeper has its simple and reliable data model. Data model, coupled with data synchronization, consistency processing and reliability, has many classical applications, such as distributed locking, server dynamic online and offline awareness, master node election, data publishing and subscription, load balancing and so on.
Data model
In zookeeper, it can be said that all the data stored in zookeeper is composed of znode, the node is also called znode, and stores data in the form of key/value.
The overall structure is similar to that of the linux file system, which is stored in a tree structure. Where the root path begins with /.
Enter the bin directory of the zookeeper installation, open the command line terminal through sh zkCli.sh, and execute the "ls /" command to display:
$ls / $ls / zookeeper$ ls / zookeeper/quota
We can see intuitively that the stored data has two nodes runoob and zookeeper under the root directory and quota node under the zookeeper node.
The runoob node was created in our previous chapter and set the value 0 through the java client. Now we perform get / runoob at the command line terminal to display the properties of this node.
An introduction to the get / runoobZooKeeper data model introduction to the ZooKeeper data model introduction to the state attribute of Znode the transaction when the node was created, the transaction when the node was created, the time when the node was last modified, the transaction IDmtime when the node was last modified, the time pZxid represents the last modified transaction ID of the node's child node list, adding or deleting the child node will affect the child node list, but modifying the data content of the child node does not affect the ID** (note The pzxid will be changed only if the list of child nodes is changed, and the change in the content of the child node will not affect the version number of the child node. Each time the child node modifies the version number, it will be added to the 1dataversion data version number, and each time the data is modified, the version number will be added to the 1aclversion permission version number, and each time the permission will be modified plus the sessionID of the session in which the temporary node is created by 1ephemeralOwner. * * (* * if the node is persistent, then the attribute value is 0) dataLength the data length of the node numChildren the number of child nodes that the node has * * (only count the number of direct child nodes) * *
Show details
Knowing the above state attribute value, let's make a modification to the / runoob node and execute the command set / runoob 1, as shown in the following figure:
$set / runoob 1
Comparing the above results, you can see that mZxid, mtime, and dataVersion have all changed.
Under the / runoob node, we add another child node and execute:
$create-e / runoob/child 0$ get / runoob
Tip: the use of more commands will be explained in detail in later chapters.
After executing the terminal command line, the display:
It can be seen that the pZxid, cversion and numChildren of the / runoob node have changed accordingly.
The above is all the contents of the article "how to use the Zookeeper data Model". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.