标签:PLAINTEXT CFG zookeeper KAFKA 步骤 docker kafka
首先创建一个网络
app-tier:网络名称
–driver:网络类型为bridge
docker network create app-tier --driver bridge
1、安装zookeeper
Kafka依赖zookeeper所以先安装zookeeper
-p:设置映射端口(默认2181)
-d:后台启动
docker run -d --name zookeeper-server \
--network app-tier \
-e ALLOW_ANONYMOUS_LOGIN=yes \
bitnami/zookeeper:latest
查看zookeeper容器日志(可省略)
docker logs -f zookeeper
2、安装Kafka
安装并运行Kafka,
–name:容器名称
-p:设置映射端口(默认9092 )
-d:后台启动
ALLOW_PLAINTEXT_LISTENER任何人可以访问
KAFKA_CFG_ZOOKEEPER_CONNECT链接的zookeeper
KAFKA_ADVERTISED_HOST_NAME当前主机IP或地址(重点:如果是服务器部署则配服务器IP或域名否则客户端监听消息会报地址错误)
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.0.101:9092 \
docker run -d -p30021:9092 -p30022:9093 -e KAFKA_ENABLE_KRAFT=yes \
--network app-tier \
-e KAFKA_CFG_PROCESS_ROLES=broker,controller \
-e KAFKA_CFG_MESSAGE_MAX_BYTES=23068672 \
-e KAFKA_CFG_MAX_REQUEST_SIZE=23068672 \
-e KAFKA_CFG_MAX_PARTITION_FETCH_BYTES=23068672 \
-e KAFKA_CFG_LOG_RETENTION_HOURS=12 \
-e KAFKA_CFG_LOG_RETENTION_CHECK_INTERVAL_MS=300000 \
-e KAFKA_CFG_LOG_RETENTION_BYTES=23068672 \
-e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
-e KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT \
-e
[email protected]:9093 \
-e KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.40.92.28:30021 \
-e KAFKA_BROKER_ID=1 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
--name kafka bitnami/kafka:3.2
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.40.92.28:30021 \
自己的ip:端口
查看kafka容器日志(可省略)
docker logs -f kafka
3、kafka-map图形化管理工具
图形化管理工具
访问地址:http://服务器IP:9001/
DEFAULT_USERNAME:默认账号admin
DEFAULT_PASSWORD:默认密码admin
Git 地址:https://github.com/dushixiang/kafka-map/blob/master/README-zh_CN.md
docker run -d --name zookeeper-server \
--network app-tier \
-e ALLOW_ANONYMOUS_LOGIN=yes \
bitnami/zookeeper:latest
标签:PLAINTEXT,
CFG,
zookeeper,
KAFKA,
步骤,
docker,
kafka
From: https://www.cnblogs.com/LiuOOP/p/17085183.html