Skip to content

ZooKeeper single-server setup

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. Setting up a single-server instance involves configuring the data directory and network ports.^[600-developer__big-data__zookpeeper__zookpeeeper-01.md]

Installation

The setup process begins by extracting the ZooKeeper archive and creating a default configuration file from the provided sample^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

The standard configuration file is located at /opt/zookeeper/conf/zoo.cfg^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

Configuration

The configuration file zoo.cfg requires specific parameters to function correctly^[600-developer__big-data__zookpeeper__zookpeeeper-01.md]. The essential properties for a basic setup are:

  • clientPort: The port listened to by client connections (default is 2181)^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].
  • dataDir: The directory where the snapshot is stored^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

It is recommended to avoid using /tmp for storage in production environments; instead, use a dedicated path such as /opt/zookeeper/data/zkData^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

clientPort=2181
dataDir=/opt/zookeeper/data/zkData

Data Directory Initialization

Before starting the server, the data directory specified in zoo.cfg must be created^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

mkdir -p /opt/zookeeper/data/zkData

Server Management

ZooKeeper provides a script zkServer.sh to manage the server lifecycle^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

  • Start the server: bin/zkServer.sh start
  • Check status: bin/zkServer.sh status
  • Stop the server: bin/zkServer.sh stop

You can verify that the ZooKeeper process is running using the jps command^[600-developer__big-data__zookpeeper__zookpeeeper-01.md].

  • ZooKeeper
  • [[Clustered (Multi-Server) Setup]]

Sources

  • 600-developer__big-data__zookpeeper__zookpeeeper-01.md