ZooKeeper - studiofu/brain GitHub Wiki

Quick Start

ZooKeeper本身是一個分布式應用程序,為寫入分布式應用程序提供服務。

Apache ZooKeeper是由集群(節點組)使用的一種服務,用於在自身之間協調,並通過穩健的同步技術維護共享數據。

Simple Testing Through Docker

# create zookeeper and the required port is 2181
docker run -d --name zookeeper -p 2181:2181 jplock/zookeeper

# create kafka and the required ports are 7203 and 9092
docker run -d --name kafka -p 7203:7203 -p 9092:9092 -e KAFKA_ADVERTISED_HOST_NAME=<HOST_IP> -e ZOOKEEPER_IP=<HOST_IP> ches/kafka

# create the kafka topics senz
docker run --rm ches/kafka kafka-topics.sh --create --topic senz --replication-factor 1 --partitions 1 --zookeeper <HOST_IP>:2181

# list the kafka topics
docker run --rm ches/kafka kafka-topics.sh --list --zookeeper <HOST_IP>:2181

# produce messages for testing
docker run --rm --interactive ches/kafka kafka-console-producer.sh --topic senz --broker-list <HOST_IP>:9092

# consume messages
docker run --rm ches/kafka kafka-console-consumer.sh --topic senz --from-beginning --zookeeper <HOST_IP>:2181

# access zookeeper for testing
docker exec -it zookeeper bash

# access zookeeper cli
bin/zkCli.sh -server 127.0.0.1:2181

# access the key value in zookeeper cli
ls /

# create node
create /path /data

# create node with value
create /mytest1 value1

# set node value
set /mytest1 value2

# show stats
stat /mytest1

# check zookeeper status 
./zkServer.sh status

Resources

Apache ZooKeeper 介紹

https://medium.com/@toofun/apache-zookeeper-%E4%BB%8B%E7%B4%B9-387ea3097e7c

Kafka and Zookeeper with Docker

https://medium.com/rahasak/kafka-and-zookeeper-with-docker-65cff2c2c34f

Kafka/Zookeeper cluster on kubernetes

https://medium.com/rahasak/kafka-zookeeper-cluster-on-kubernetes-43a4aaf27dbb

Zookeeper CLI

https://m.w3cschool.cn/zookeeper/zookeeper_cli.html https://medium.com/develbyte/zookeeper-namespace-and-operations-4bdbbee5ab37

How To Install and Configure an Apache ZooKeeper Cluster on Ubuntu 18.04

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-an-apache-zookeeper-cluster-on-ubuntu-18-04

ZooKeeper, Curator and how microservices load balancing works

http://tomaszdziurko.com/2014/07/zookeeper-curator-and-microservices-load-balancing/

⚠️ **GitHub.com Fallback** ⚠️