I am currently studying the Hadoop Ecosystem and keep seeing Apache ZooKeeper mentioned as a core component for services like HBASE and HDFS. Can someone explain exactly what ZooKeeper does? Is it just a centralized repository for configuration, or does it play a more active role in leader election and node synchronization? I’m specifically interested in how it prevents "split-brain" scenarios during a NameNode failover in a production environment.
3 answers
Apache ZooKeeper is a distributed coordination service that acts as a "source of truth" for large-scale clusters. In the Hadoop Ecosystem, its primary purpose is to maintain configuration information, provide distributed synchronization, and handle group services. Think of it as a highly available file system for metadata. For HDFS High Availability, ZooKeeper maintains a persistent session with the NameNodes; if the Active NameNode fails, ZooKeeper detects the heartbeat loss and triggers the ZKFailoverController (ZKFC) to elect the Standby NameNode as the new Active. This ensures that the cluster continues to function without manual intervention or data loss, effectively managing the complex state of distributed systems.
How does ZooKeeper ensure that its own data remains consistent across the "Ensemble" if one of the ZooKeeper nodes itself goes offline during a leader election process in Hadoop?
ZooKeeper basically acts as a traffic cop for Hadoop. It manages the "locks" that prevent two different servers from trying to write the same data at the same time.
I agree with Jessica. Without those distributed locks and the centralized synchronization ZooKeeper provides, managing a 100-node Hadoop cluster would be a nightmare of race conditions and inconsistent configurations.
Steven, that is handled by the Zab (ZooKeeper Atomic Broadcast) protocol. ZooKeeper uses a "Quorum" system, meaning as long as a majority of the nodes in the ensemble (e.g., 2 out of 3, or 3 out of 5) are active, the service remains functional. The Zab protocol ensures that all state changes are processed in the same order across all followers. This strict consistency model is exactly what allows Hadoop components like Kafka or HBase to rely on ZooKeeper for critical tasks like offset management or region assignment without worrying about data corruption.