Docker - Kafka部署(集群Kraft版,不依赖zookeeper)
Apache Kafka 是一种高吞吐量、持久性、分布式的发布订阅的消息队列系统,也常应用于大数据实时处理领域。它最初由LinkedIn(领英)公司发布,使用Scala语言编写,与2010年12月份开源,成为Apache的顶级子项目。
一、拉取镜像
docker pull bitnami/kafka:3.3.2
# 可视化界面
docker pull freakchicken/kafka-ui-lite:1.2.11
二、启动程序
主机1:192.168.1.101
docker run -d \
-p 9092:9092 \
-p 9093:9093 \
--name=kafka-node1 \
--restart=unless-stopped \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
# 数据映射
-v /data/kafka/kraft:/bitnami/kafka:rw \
# 节点ID
-e KAFKA_CFG_NODE_ID=1 \
# 启用Kraft模式
-e KAFKA_ENABLE_KRAFT=yes \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_PROCESS_ROLES=broker,controller \
# KRaft模式时集群ID必须指定,密码长度必须为22位,否则启动不成功
-e KAFKA_KRAFT_CLUSTER_ID=manongdashu66666666666 \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
# 连接的集群地址,格式为: id1@host1:port1,id2@host2:port2
-e KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@192.168.1.101:9093,2@192.168.1.102:9093,3@192.168.1.103:9093 \
bitnami/kafka:3.3.2
主机2:192.168.1.102
docker run -d \
-p 9092:9092 \
-p 9093:9093 \
--name=kafka-node2 \
--restart=unless-stopped \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /data/kafka/kraft:/bitnami/kafka:rw \
-e KAFKA_CFG_NODE_ID=2 \
-e KAFKA_ENABLE_KRAFT=yes \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_PROCESS_ROLES=broker,controller \
-e KAFKA_KRAFT_CLUSTER_ID=manongdashu66666666666 \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
-e KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@192.168.1.101:9093,2@192.168.1.102:9093,3@192.168.1.103:9093 \
bitnami/kafka:3.3.2
主机3:192.168.1.103
docker run -d \
-p 9092:9092 \
-p 9093:9093 \
--name=kafka-node3 \
--restart=unless-stopped \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /data/kafka/kraft:/bitnami/kafka:rw \
-e KAFKA_CFG_NODE_ID=3 \
-e KAFKA_ENABLE_KRAFT=yes \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_PROCESS_ROLES=broker,controller \
-e KAFKA_KRAFT_CLUSTER_ID=manongdashu66666666666 \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
-e KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@192.168.1.101:9093,2@192.168.1.102:9093,3@192.168.1.103:9093 \
bitnami/kafka:3.3.2
可视化管理界面
# 创建配置文件存放目录
mkdir -p /data/kafka/kafka-ui-lite/conf
# 创建临时容器并Copy文件到目录
docker create --name kafka-ui-lite freakchicken/kafka-ui-lite:1.2.11 \
&& docker cp kafka-ui-lite:/kafka-ui-lite-1.2.11/conf /data/kafka/kafka-ui-lite \
&& docker rm kafka-ui-lite
docker run -d \
-p 8889:8889 \
--name=kafka-ui-lite \
--restart=unless-stopped \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /data/kafka/kafka-ui-lite/conf:/kafka-ui-lite-1.2.11/conf \
freakchicken/kafka-ui-lite:1.2.11
三、访问测试
THE END
二维码
打赏
文章目录
关闭
cialis online
Hi there I am so excited I found your blog, I really found you by error, while I was looking on Yahoo for something else, Regardless I am here now and would just like to say thanks for a marvelous post and a all round interesting
blog (I also love the theme/design), I don't have time to go through it all at the moment but I have saved it and also added in your RSS
feeds, so when I have time I will be back to read more, Please
do keep up the fantastic job.