Mac上通过docker-compose搭建Kafka学习环境

Kafka docker-compose
提供一个单机zk、集群kafka和kafka-manager,供学习使用。

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
    volumes:
      - "./zookeeper/data:/data"
      - "./zookeeper/datalog:/datalog"

  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092"             # kafka 把9092端口随机映射到主机的端口
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 10.2.46.144           #本机ip ********修改
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_CREATE_TOPICS: test:1:1
      KAFKA_DELETE_TOPIC_ENABLE: "true"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./kafka/logs:/kafka
  kafka-manager:
    image: sheepkiller/kafka-manager
    links:
      - zookeeper
    environment:
      ZK_HOSTS: zookeeper:2181
      APPLICATION_SECRET: letmein
      KM_ARGS: -Djava.net.preferIPv4Stack=true
    ports:
      - "9000:9000"

使用

docker-compose up -d --scale kafka=3 
docker-compose down	停止、删除所有的服务以及网络、镜像
docker-compose stop	停止所有服务
``

你可能感兴趣的:(消息中间件,Kafka,Docker)