当前位置:   article > 正文

docker-compose 部署kafka

docker-compose 部署kafka

https://blog.csdn.net/Crystalqy/article/details/94006936

 

docker-compose部署kafka

docker-compose.yml如下:

  1. version: '2'
  2. services:
  3. zookeeper:
  4. container_name: zookeeper
  5. image: wurstmeister/zookeeper
  6. volumes:
  7. - ./zookeeper/data:/data
  8. ports:
  9. - "2181:2181"
  10. kafka:
  11. container_name: kafka
  12. image: wurstmeister/kafka
  13. ports:
  14. - "9092:9092"
  15. environment:
  16. KAFKA_ADVERTISED_HOST_NAME: localhost
  17. KAFKA_MESSAGE_MAX_BYTES: 2000000
  18. KAFKA_CREATE_TOPICS: "test:1:1"
  19. KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
  20. volumes:
  21. - ./kafka:/kafka
  22. - /var/run/docker.sock:/var/run/docker.sock
  23. kafka-manager:
  24. container_name: kafka-manager
  25. image: sheepkiller/kafka-manager
  26. ports:
  27. - 9020:9000
  28. environment:
  29. ZK_HOSTS: zookeeper:2181

参数说明:

  • KAFKA_ADVERTISED_HOST_NAME:Docker宿主机IP(如果你要配置多个brokers,就不能设置为 localhost 或 127.0.0.1)
  • KAFKA_MESSAGE_MAX_BYTES:kafka(message.max.bytes) 会接收单个消息size的最大限制,默认值为1000000 , ≈1M
  • KAFKA_CREATE_TOPICS:初始创建的topics,可以不设置
  • 环境变量./kafka为防止容器销毁时消息数据丢失。
  • 容器kafka-manager为yahoo出可视化kafka WEB管理平台。

在docker-compose.yml所在目录下执行:

  1. # 启动:
  2. $ docker-compose up -d
  3. # 删除容器:
  4. $ docker-compose down
  5. # 增加更多Broker:
  6. $ docker-compose scale kafka=3
  7. # 合并:
  8. $ docker-compose up --scale kafka=3

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/651990
推荐阅读
相关标签
  

闽ICP备14008679号