docker-compose 安装kafka 集群版&单机版

单机版

version: '3'
services:
  zookeeper:
    image: wurstmeister/zookeeper   
    ports:
      - "2181:2181"                 
  kafka:
    image: wurstmeister/kafka       
    volumes: 
        - /etc/localtime:/etc/localtime
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.200.11   ## 宿主机IP
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181      
      KAFKA_ADVERTISED_PORT: 9092
  kafka-manager:  
    image: sheepkiller/kafka-manager:latest                
    environment:
        ZK_HOSTS:  192.168.200.11                  ## zookeeper地址
    ports:  
      - "9001:9000"                                 # 宿主机port:container_port

集群

version: '3'
services:
   # zookeeper:
   #    image: wurstmeister/zookeeper   
   #    container_name: zookeeper
   #    ports:
   #       - "2181:2181"    


   kafka1:
      image: wurstmeister/kafka 
      container_name: kafka1      
      volumes: 
         - ./localtime1:/etc/localtime
      ports:
         - "9092:9092"
      environment:
         KAFKA_ADVERTISED_HOST_NAME: 192.168.200.11   ## 宿主机IP
         KAFKA_BROKER_ID: 0      #指定kafka的id
         # KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.200.11:9092    # 修改:宿主机IP
         KAFKA_ZOOKEEPER_CONNECT: 192.168.200.11:2181     
         KAFKA_MESSAGE_MAX_BYTES: 2000000 
         KAFKA_ADVERTISED_PORT: 9092


   kafka2:
      image: wurstmeister/kafka
      container_name: kafka2      
      volumes:
         - ./localtime2:/etc/localtime
      ports:
         - "9093:9092"
      environment:
         KAFKA_ADVERTISED_HOST_NAME: 192.168.200.11   ## 宿主机IP
         # KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.200.11:9092    # 修改:宿主机IP
         KAFKA_BROKER_ID: 1      #指定kafka的id      
         KAFKA_MESSAGE_MAX_BYTES: 2000000 
         KAFKA_ZOOKEEPER_CONNECT: 192.168.200.11:2181      
         KAFKA_ADVERTISED_PORT: 9093


   kafka3:
      image: wurstmeister/kafka
      container_name: kafka3      
      volumes:
         - ./localtime3:/etc/localtime
      ports:
         - "9094:9092"
      environment:
         KAFKA_ADVERTISED_HOST_NAME: 192.168.200.11   ## 宿主机IP
         # KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.200.11:9092    # 修改:宿主机IP
         KAFKA_BROKER_ID: 2      #指定kafka的id
         KAFKA_MESSAGE_MAX_BYTES: 2000000 
         KAFKA_ZOOKEEPER_CONNECT: 192.168.200.11:2181      
         KAFKA_ADVERTISED_PORT: 9094


   kafka-manager:  
      image: sheepkiller/kafka-manager:latest                
      environment:
         ZK_HOSTS:  192.168.200.11:2181                  ## zookeeper地址
      ports:  
         - "9001:9000"                                   # 宿主机port:container_port
     
# kafdrop:
#    image: obsidiandynamics/kafdrop
#    container_name: kafdrop
#    restart: "no"
#    ports:
#      - "9000:9000"
#    environment:
#       KAFKA_BROKERCONNECT: "192.168.200.11:9092"

上一篇:FX3U写的分期付款程序,可以无限期次,按生产产量或按天数


下一篇:centos7安装docker和docker-compose