How to implement zookeeper cluster management (file system and notification mechanism)?

Alibaba cloud Q & A 2022-02-13 06:12:45 阅读数:252

implement zookeeper cluster management file

Zookeeper Cluster management ( file system 、 A notification mechanism ), How to achieve ?




Take the answer 1:

Cluster management doesn't care about two things : Whether there are machines to exit and join 、 The election master.

For the first point , All machine conventions create temporary directory nodes in the parent directory , Then listen to the parent directory node

Child node change message for . Once a machine hangs up , The machine and zookeeper Is disconnected , The temporary directory node it created is deleted , All other machines are notified : A sibling directory was deleted , therefore , Everybody knows that : It's on board .

New machines are similar , All machines are notified : New brother directory added ,highcount Have a , For the second point , Let's change it a little bit , All machines create temporary sequence number directory nodes , Select the machine with the smallest number as master Just fine .


copyright:author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130612442017.html