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

Big data's ecological zookeeper (typical application scenarios)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

1. naming service

Naming service is a common scenario in distributed systems. In distributed systems, named entities can usually be machines in clusters, service addresses provided, or remote objects. Through naming service, clients can obtain information about resource entities, service addresses, and providers according to specified names. Zookeeper can help applications locate and use resources by referring to them. Zookeeper can also help the application system to locate and use resources through resource reference methods. In a broad sense, the resource location of naming services is not a real entity resource. In a distributed environment, upper applications only need a globally unique name. Zookeeper can implement a mechanism for distributing globally unique IDs.

2. configuration management

Programs always need to be configured. If programs are distributed to various machines, it becomes difficult to change the configuration one by one. Now these configurations are all put into zookeeper and saved in a directory node of zookeeper. Then all related applications listen to this directory node. Once the configuration information changes, each application will receive notification from zookeeper, and then obtain new configuration information from zookeeper and apply it to the system. For example: Take the installation of Hadoop cluster as an example. The configuration file of each node in the cluster is unified. When zk manages the configuration file, monitor whether the content of the configuration file has been modified, whether the configuration file has been added or deleted. so that configuration file can be synchronized across cluster node.

3. cluster management

The so-called cluster management is divided into two parts: whether there are machines joining/exiting, and electing masters.

(1) Whether there are node machines joining or exiting

All machine conventions create temporary directory nodes under the parent directory GroupMembers, and then listen for information about changes in the child nodes of the parent directory node. Once a machine is down, it is disconnected from zookeeper and the temporary node directory it created is deleted. All the other machines were notified that a sibling directory had been deleted, and everyone knew that a sibling had died. The same is true for new machines. All machines are notified that a new sibling has been added to the directory.

(2) Election of the Master

Create temporary sequentially numbered directory nodes for all machines, selecting the lowest numbered machine as master each time.

4. distributed lock

There are three kinds of locks in zk: write lock, read lock and timing lock.

Write lock: A temporary unnumbered node created on zk. Because it is an out-of-order number, it is not automatically numbered when it is created, resulting in only one client getting the lock and then writing.

Read lock: Create a temporary numbered node on zk, so that even if a client joins and creates the same node at the same time, it will automatically number it, and it can obtain the lock object and read it.

Temporal lock: A temporary numbered node created on zk controls the lock based on the size of the number.

5. Queue management

There are two ways to manage queues in zk:

(1) Synchronous queue: A queue is available only when all members of the queue are gathered, otherwise it waits for all members to arrive.

Function: Create temporary directory nodes under the contract directory, listen to whether the number of nodes is the number we require.

(2) First-in-first-out queue: queue according to FIFO mode for enqueue and dequeue operation.

Function: The basic principle is consistent with that of the control timing scenario in distributed lock service. The columns are numbered and the columns are numbered.

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

Internet Technology

Wechat

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

12
Report