Zookeeper
Introduction
Apache ZooKeeper is a centralized coordination service for distributed systems, providing primitives for configuration management, naming, distributed synchronization, and group services. It exposes a hierarchical key-value namespace (znodes) with strong ordering guarantees and is widely used as the coordination backend for Kafka, HBase, Hadoop, and many legacy distributed systems.
How to Install
Starting via Binary
Quick Start
bash
# download source
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin zookeeper-3.7.1 && cd zookeeper-3.7.1Config and Boot
Config
bash
# create data and logs dir
mkdir -p /opt/zookeeper-3.7.1/data
mkdir -p /opt/zookeeper-3.7.1/logs
cat > /opt/zookeeper-3.7.1/conf/zoo.cfg << "EOF"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper-3.7.1/data
dataLogDir=/opt/zookeeper-3.7.1/logs
clientPort=2181
# cluster mode: service communication and election
# server.0=1.1.1.1:2888:3888
# server.1=1.1.1.2:2888:3888
# server.2=1.1.1.3:2888:3888
maxClientCnxns=300
admin.enableServer=false
EOF
# create version_id file if cluster mode
# echo 0 > /opt/zookeeper-3.7.1/data/myid
# echo 1 > /opt/zookeeper-3.7.1/data/myid
# echo 2 > /opt/zookeeper-3.7.1/data/myidBoot(systemd)
bash
cat > /etc/systemd/system/zookeeper.service << "EOF"
[Unit]
Description=Zookeeper Server
Documentation=https://zookeeper.apache.org/
After=network.target
Wants=network-online.target
[Service]
Type=forking
# Environment=JAVA_HOME=/opt/jdk11
ExecStart=/opt/zookeeper-3.7.1/bin/zkServer.sh start
ExecStop=/opt/zookeeper-3.7.1/bin/zkServer.sh stop
ExecReload=/opt/zookeeper-3.7.1/bin/zkServer.sh restart
Restart=on-failure
RestartSec=5s
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start zookeeper.service
systemctl enable zookeeper.serviceStarting via Docker
bash
# https://hub.docker.com/_/zookeeperStarting via Kubernetes
Install by Helm
bash
# Add and update repo
helm repo add bitnami https://charts.bitnami.com/bitnami --force-update
# Get charts package
helm pull bitnami/zookeeper --untar --version=13.8.7
cd zookeeper
# Install and verify
helm -n middleware install zookeeper . --set global.storageClass=nfs-client --set replicaCount=3 --create-namespace
kubectl -n middleware exec -it zookeeper-0 -- zkServer.sh statusReference: