kafka cluster by docker

--

使用Docker可以很方便的建立一个kafka cluster.

将下边的内容保存在一个文件中,命名为docker-compse.yaml。

version: '2'
services:
  zookeeper:
    image: zookeeper
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka
    links:
      - zookeeper:zk
    ports:
      - "9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_MESSAGE_MAX_BYTES: 2000000
      KAFKA_CREATE_TOPICS: "Topic1:1:1" 
    depends_on:
      - zookeeper
  kafka-manager:
    image: sheepkiller/kafka-manager
    ports:
      - "9000:9000"
    environment:
      ZK_HOSTS: "zookeeper:2181"
      APPLICATION_SECRET: "admin"
    depends_on:
      - zookeeper      

执行以下命令启动一个有5个broker的kafka cluster

docker-compose up -d --sacle kafka=5
Show Comments