当前位置:   article > 正文

docker-composer搭建kafka集群_docker-compse kafka cluster

docker-compse kafka cluster

docker-composer搭建kafka集群

一、创建docker内的zookeeper集群和kafka集群网段:

docker network create kafkacluster_default
  • 1

二、zookeeper 集群安装

docker-compose-zookeeper-cluster.yml

version: '3.5'

networks:
  kafkacluster_default:
      external: true

services:
  zoo1:
    image: zookeeper
    restart: unless-stopped
    hostname: zoo1
    container_name: zoo1
    ports:
      - 2182:2181
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    volumes:
      - /usr/local/zookeeper/zoo1/data:/data
      - /usr/local/zookeeper/zoo1/datalog:/datalog
    networks:
      - kafkacluster_default
  zoo2:
    image: zookeeper
    restart: unless-stopped
    hostname: zoo2
    container_name: zoo2
    ports:
      - 2183:2181
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo3:2888:3888;2181
    volumes:
      - /usr/local/zookeeper/zoo2/data:/data
      - /usr/local/zookeeper/zoo2/datalog:/datalog
    networks:
      - kafkacluster_default
  zoo3:
    image: zookeeper
    restart: unless-stopped
    hostname: zoo3
    container_name: zoo3
    ports:
      - 2184:2181
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181
    volumes:
      - /usr/local/zookeeper/zoo3/data:/data
      - /usr/local/zookeeper/zoo3/datalog:/datalog
    networks:
      - kafkacluster_default

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53

启动zookeeper集群

docker-compose -f docker-compose-zookeeper-cluster.yml up -d
  • 1

三、kafka 集群安装和kafka-manager

docker-compose-kafka-cluster.yml

version: '3.5'

networks:
  kafkacluster_default:
    external: true

services:
  kafka1:
    image: wurstmeister/kafka
    restart: unless-stopped
    container_name: kafka1
    ports:
      - "9093:9092"
    external_links:
      - zoo1
      - zoo2
      - zoo3
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.111 ## 修改:宿主机IP
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/652108
推荐阅读
相关标签
  

闽ICP备14008679号