安装 zookeeper
使用官方版本:https://hub.docker.com/_/zookeeper/
# pull
docker pull zookeeper
docker pull zookeeper
# run
docker run \
--name zookeeper \
--restart always \
-p=2181:2181 \
-d zookeeper
docker run \
--name zookeeper \
--restart always \
-p=2181:2181 \
-d zookeeper
安装 kafka
由于官方没有提供,推荐直接使用 https://hub.docker.com/r/wurstmeister/kafka/
# pull
docker pull wurstmeister/kafka
docker pull wurstmeister/kafka
# Get Current Docker Host IP
ip addr | grep "global docker"
ip addr | grep "global docker"
# run
docker run --name kafka \
--restart always \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=172.17.0.1:2181 \
-p 9092:9092 \
-d wurstmeister/kafka
docker run --name kafka \
--restart always \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=172.17.0.1:2181 \
-p 9092:9092 \
-d wurstmeister/kafka
创建 Topic
# entry containner
docker exec -it kafka /bin/bash
/opt/kafka/bin
docker exec -it kafka /bin/bash
/opt/kafka/bin
# add topic
/kafka-topics.sh --create \
--topic TestTopic \
--replication-factor 1 \
--partitions 20 \
--zookeeper 172.17.0.1:2181
/kafka-topics.sh --create \
--topic TestTopic \
--replication-factor 1 \
--partitions 20 \
--zookeeper 172.17.0.1:2181
# alter Topic
./kafka-topics.sh \
--zookeeper 172.17.0.1:2181 \
--alter --partitions 20 \
--topic TestTopic
./kafka-topics.sh \
--zookeeper 172.17.0.1:2181 \
--alter --partitions 20 \
--topic TestTopic
当前还没有任何评论