docker-compose部署kafka
阿新 • • 發佈:2018-12-31
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)