docker-compse 启动文件
version: '3'
name: kafka1
services:
zookeeper:
image: bitnami/zookeeper:latest
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
# volumes:
# - zookeeper_vol:/data
# - zookeeper_vol:/datalog
# - zookeeper_vol:/logs
container_name: zookeeper
kafka:
image: bitnami/kafka:latest
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: "localhost"
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
# KAFKA_LOG_DIRS: "/home"
# volumes:
# - kafka_vol:/kafka
depends_on:
- zookeeper
container_name: kafka
#volumes:
# zookeeper_vol: {}
# kafka_vol: {}
启动一个命令行,生产
docker-compose -f kafa-group.yml up -d
docker exec -it kafka /bin/bash
cd /opt/bitnami/kafka/bin
sh kafka-console-producer.sh --broker-list localhost:9092 --topic test
另开一个命令行,消费
docker exec -it kafka /bin/bash
cd /opt/bitnami/kafka/bin
sh kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
在生产中输入字符
消费端接收到
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » docker 部署kafka,zokeeper,快速开发模式
发表评论 取消回复