docker-compose部署kafka介绍如下:

编写docker-compose.yml文件,将文件中IP修改为本机ip,docker-compose.yml文件内容如下:

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka1:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.128
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_delete_topic_enable: 'true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  kafka2:
    image: wurstmeister/kafka
    ports:
      - "9093:9092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.128
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_delete_topic_enable: 'true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  kafka3:
    image: wurstmeister/kafka
    ports:
      - "9094:9092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.128
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_delete_topic_enable: 'true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

进入docker-compose.yml文件所在目录,执行如下命令

docker-compose up

问题:kafka1_1     | [2018-10-10 02:34:17,680] WARN [Controller id=1, targetBrokerId=1] Connection to node 1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

 

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐