table of Contents
What is the zookeeper
Definitions: zookeeper is an open source distributed coordination service, a typical distributed data consistency solutions.
Past and Present: Yahoo created originally for the sub hadoop is google Chubby open source implementation, is now a top-level Apache project.
Distributed applications can publish a subscription-based zookeeper for data, load balancing, name services, distributed lock, cluster management and other functions.
zookeeper provide any capability
zookeeper build a distributed cluster can ensure that the following agreement
- Sequential consistency
Multiple transactions initiated by a request from the same client will initiate strict accordance with the order applied to all nodes
- Atomicity
The processing results of all transaction requests consistent application of all cluster machines. All machines use either all, or all not applied.
- A single view
No matter which node is connected, the effect is the same
- reliability
Once a transaction is applied, then the state of affairs will be maintained
- real-time
zookeeper guarantee a certain period of time , the client reads from the server to the latest state
zookeeper features
Simple Data Model
zk data model is a shared namespace tree tree structure. Znode composed of a series, is referred to znode data nodes having a hierarchical relationship. zk The total amount of data stored in memory, the server in order to achieve improved throughput, reduce delay purposes
It may constitute a cluster
zk cluster consists of a group of machines, units 3 to 5 can, each cluster consisting zk machine maintenance memory in the current state of the server, and maintained between each machine communicate with each other. As long as the cluster than the average machine to work properly, the whole cluster can be normal external services
Sequential Access
For each update request from the client, ZK is assigned a globally unique incremental number, transaction operations are executed in accordance with this order number, and the characteristics may be useful for other purposes.
high performance
The total amount of data is stored in memory, and direct services to all non-transactional client's request, especially for read operations dominated the scene.
The basic concept of zookeeper
The basic concept introduced here only zk and simple to explain, explain in detail the follow-up to do
Cluster role
- Leader
A, providing literacy
- Follower
More offers and reading skills, ability elections Leader
- Observer
Multiple, providing the ability to read, not to participate in elections
Conversation
TCP is a connection between long zk client and the server. sessionTimeout provided a session timeout, the connection is disconnected when abnormal, as long as the connection time-out on any node zk, before the session is still valid.
node
1. machine node
Constitute a cluster of machines
2. Data node ZNode
ZNode data node the data unit in the data model. The data model is a tree, a slash (/) of the divided route, the data stored content and properties. Persistent nodes and can be divided into two types of temporary node
version
Each has a stat ZNode above data structure, the data recorded three versions:
- version: The current version ZNode
- cversion: The current version ZNode child nodes
- aversion: The current version ZNode of ACL
ACL
(Access control lists) access control list
- CREATE: create a child node rights
- READ: Get Permissions node data and list of children
- WRITE: update node data permissions
- DELETE: delete child nodes of authority
- ADMIN: Setting Node ACL permissions
create and delete permissions on all child nodes of control
Watcher
Event listener. Important characteristics of zk, zk allow users to register an event to a specific node, when a particular time-triggered event notification is sent to a specific client.