ZooKeeper is a distributed, high-availability coordination service that provides distributed configuration, synchronization, and naming services.
Basic principles
A ZooKeeper cluster must have an odd number of nodes (2N+1). An internal election protocol selects one node as the Leader, and the remaining nodes become Followers. When writing data, the Leader node coordinates all write requests. A write operation is successful only if at least (N+1) nodes vote for it, so at least (N+1) active nodes are required for the ZooKeeper service to be available. If the Leader node fails, the cluster holds a new election to choose a new Leader, ensuring high availability.
Data organization
ZooKeeper organizes data in a tree structure using znodes (ZooKeeper nodes). Unlike a standard file system, a znode does not distinguish between a folder or a file, and each znode can store data.
As a coordination service, znodes are primarily used to store coordination data, such as service status and configuration information. Do not use ZooKeeper as a file system to store large amounts of data.