作者:沈自在
1 Docker 安装
1.1 编写 Docker compose 文件
通过 docker compose
便捷安装 Kafka
以及 Kafka UI
文章来源:https://www.toymoban.com/news/detail-784408.html
version: "3"
services:
kafka:
image: 'bitnami/kafka:latest'
container_name: kafka
ports:
- "9092:9092"
- "9093:9093"
volumes:
- type: volume
source: kafka_standalone_data
target: /bitnami/kafka
read_only: false
environment:
- BITNAMI_DEBUG=yes
# 启用KRaft模式必须设置下面三个属性
- KAFKA_CFG_NODE_ID=1
- KAFKA_CFG_PROCESS_ROLES=broker,controller
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
# broker id
- KAFKA_BROKER_ID=1
# listener的各种配置
- KAFKA_CFG_LISTENERS=CONTROLLER://:9094,BROKER://:9092,EXTERNAL://:9093
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,BROKER:PLAINTEXT,EXTERNAL:PLAINTEXT
# 注意EXTERNAL配置的是当前Docker所在的主机地址,BROKER可以使用Docker内部的网络地址即可
- KAFKA_CFG_ADVERTISED_LISTENERS=BROKER://kafka:9092,EXTERNAL://192.168.0.101:9093
# 内部各个broker之间通信用的listener
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=BROKER
# 用来进行选举的Controller服务器,如果有多个Controller则都需要写上,这里本机
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@127.0.0.1:9094
- ALLOW_PLAINTEXT_LISTENER=yes
kafka-ui:
container_name: kafka-ui
image: provectuslabs/kafka-ui:latest
ports:
- "9095:8080"
depends_on:
- kafka
environment:
KAFKA_CLUSTERS_0_NAME: kafka-stand-alone
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
KAFKA_CLUSTERS_0_METRICS_PORT: 9997
SERVER_SERVLET_CONTEXT_PATH: /kafkaui
AUTH_TYPE: "LOGIN_FORM"
SPRING_SECURITY_USER_NAME: admin
SPRING_SECURITY_USER_PASSWORD: thr010410
DYNAMIC_CONFIG_ENABLED: 'true'
volumes:
kafka_standalone_data:
driver: local
1.2 启动构建
只需要在该文件所在的目录下,执行该命令即可:文章来源地址https://www.toymoban.com/news/detail-784408.html
docker-compose -f docker-compose.yml up -d
1.3 访问页面
http://localhost:9095/kafkaui/auth
到了这里,关于使用Docker/Docker Compose 快捷安装Kafka的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!