I. Overview
The official explanation on the document so zookeeper, it is a distributed service framework is a subproject of Apache Hadoop, which is mainly used to solve some of the data management problems often encountered in distributed applications, such as: a unified naming service, state synchronization service, cluster management, and management of distributed application configuration items
simply zookeeper = + monitor file system notification mechanism
Second, the file system
1. diagram of
each subdirectory entry as NameService are called znode (directory node), and the file system, we can freely add, delete znode, add remove child znode in a znode, the only difference is that the data can be stored znode of
Four types of znode
After PERSISTENT- persistence zookeeper directory node client is disconnected, the node still exists
after the sequence number PERSISTENT_SEQUENTIAL- persistent directory node zookeeper client is disconnected, the node is still present, but Zookeeper numbered sequentially to the node name
after EPHEMERAL- temporary directory node client zookeeper is disconnected, the node is deleted
client EPHEMERAL_SEQUENTIAL- temporary directory node and numbered sequentially zookeeper Once disconnected, the node is removed, but Zookeeper numbered sequentially to the node name
Third, the sensing mechanism
The client registers its concern to monitor directory node, when the node directory changes (change data is deleted, delete the subdirectory node increases), zookeeper will notify the client.
zookeeper very powerful, distributed applications can be implemented, such as configuration management, unified naming service, state synchronization service, such as cluster management
Always need to configure the program, if the program dispersed deployed on multiple machines, one by one to change the configuration becomes difficult. Okay, now to put all these configurations zookeeper up, is stored in a directory node Zookeeper, and then all relevant applications to the directory node to monitor, once the configuration information changes, each application will receive Zookeeper notice, then get from Zookeeper new configuration information to the system just fine.