Introduction to zookeeper

MelodyYN 2022-02-13 08:26:31 阅读数:608

introduction zookeeper

Zookeeper

summary

​ Zookeeper by Distributed applications provide coordination services Of Apache project . Understand... From a design pattern perspective , It is a distributed service management framework based on observer pattern . It is responsible for storing and managing specified data , Then accept the observer's registration . Once the state of these data changes ,Zookeeper I'm responsible for informing you that it's already in Zookeeper The observers who registered on responded accordingly .

​ Zookeeper = file system + A notification mechanism .

characteristic

1、Zookeeper: A leader (Leader), Multiple followers (Follower) A cluster of .
2、 As long as there is More than half of the nodes survive ,Zookeeper The cluster can service normally .
3、 Global data consistency : Every Server Save a copy of the same data ,Client No matter which one is connected to Server, The data are consistent .
4、 The update request sequence goes on , From the same Client The update requests of are executed in the order in which they are sent .
5、 Atomicity of data updates , A data update is either successful , Or failure .
6、 The real time , Within a certain time frame ,Client Can read the latest data .

data structure

​ ZooKeeper The structure of the data model and Unix File systems are very similar , As a whole, it can be seen as a tree , Each node is called a ZNode. every last ZNode By default, it can store 1MB The data of , Every ZNode Can be uniquely identified by its path .

Application scenarios

​ The services provided include : Unified naming service 、 Unified configuration management 、 Unified cluster management 、 Server node dynamic up and down 、 Soft load balancing, etc .

Unified naming service

​ In a distributed environment , Often need to apply / Service integration — name , Easy to identify .

Unified configuration management
  1. Distributed environment , Profile synchronization is very common .
    • — General requirements in a cluster , The configuration information of all nodes is — To , such as Kafka colony .
    • After modifying the configuration file , I hope to be able to quickly synchronize to each node .
  2. ZooKeeper How to achieve ?
    • Configuration information can be written to ZooKeeper On the one Znode.
    • Each client server listens for this Znode.
    • once Znode The data in is modified ,ZooKeeper Each client server will be notified .
Unified cluster management

In distributed environment , Master the status of each node in real time be necessary ,ZooKeeper It can realize real-time monitoring of node state changes .

Server node dynamic up and down
Soft load balancing
copyright:author[MelodyYN],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130826298242.html