注意将192.168.1.193替换自己的ip
version: '2' services: # zookeeper注册中心 zookeeper: image: zookeeper ports: - "2181:2181" # kafka管理后台 kafka-manager: image: sheepkiller/kafka-manager environment: ZK_HOSTS: 192.168.1.193:2181 APPLICATION_SECRET: "GX" ports: - "9000:9000" expose: - "9000" kafka0: image: wurstmeister/kafka build: . ports: - "9092:9092" environment: KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.1.193:9092 KAFKA_BROKER_ID: 0 KAFKA_CREATE_TOPICS: "test:1:1" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 kafka1: image: wurstmeister/kafka build: . ports: - "9093:9093" environment: KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.1.193:9093 KAFKA_BROKER_ID: 1 KAFKA_CREATE_TOPICS: "test:1:1" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 kafka2: image: wurstmeister/kafka build: . ports: - "9094:9094" environment: KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9094 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.1.193:9094 KAFKA_BROKER_ID: 2 KAFKA_CREATE_TOPICS: "test:1:1" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181进入docker-compose.yml所在目录,执行命令
docker-compose up -d这样就启动成功了
http://[自己的ip]:9000 添加集群
Cluster Name:自定义名称Cluster Zookeeper Hosts:zookeeper的ip和端口 然后点击下面的save按钮