what zookeeper is.
Zookeeper, the zoo administrator, is the administrator of the Elephant (Hadoop), the Bee (Hive), the Piggy (Pig), the Apache HBase and Apache and the LinkedIn sensei, all with Z Ookeeper. Zookeeper is a distributed, open source distributed Application Coordination Service, zookeeper is based on the Fast Paxos algorithm, implementing synchronous services, configuration maintenance and naming services, and other distributed applications.
zookeeper how to work.
Zookeeper is a higher level of synchronization (synchronization), configuration management (configuration maintenance), group (groups), and name Service (naming) as a distributed application. In programming, zookeeper design is very simple, the use of the data model style is much like the file system directory tree structure, in simple terms, a bit similar to the structure of the registry in Windows, there are names, there are tree nodes, there is a key (key)/value (value) of the relationship, Can be seen as a tree-structured database, distributed on different machines for name management.
The zookeeper is divided into 2 parts: the server side and the client, and the client is connected to only one server of the entire zookeeper service. The client uses and maintains a TCP connection that sends requests, receives responses, obtains observed events, and sends heartbeats through this connection. If this TCP connection is interrupted, the client will attempt to connect to another zookeeper server. The first time a client connects to the Zookeeper service, the zookeeper server that accepts the connection establishes a session for the client. When the client connects to another server, the session is reset by the new server.
After starting the Zookeeper server cluster environment, multiple zookeeper servers elect a leader before work, and in the next job the elected leader dies, and the rest of the zookeeper server will know that this leader is dead, A leader will continue to be selected in the Living Zookeeper cluster, and the leader is chosen to ensure data consistency in a distributed environment. As shown in the figure:
In addition, zookeeper supports the concept of Watch (observation). The client can set an observation on each znode node. If the Znode node of the observed server is changed, the watch is triggered, and the client that watch belongs to will receive a notification packet that the node has changed. If the client and the connected zookeeper server are disconnected, other clients will also receive a notification, saying that a zookeeper server can be available for multiple clients, and of course multiple zookeeper server-side, as shown in the figure: