标签:浏览器 文件 address 管理 topic cluster less ESS div
version: ‘3.3‘ services: zookeeper: image: wurstmeister/zookeeper ports: - 2181:2181 container_name: zookeeper networks: default: ipv4_address: 172.22.0.11 kafka0: image: wurstmeister/kafka depends_on: - zookeeper container_name: kafka0 ports: - 9092:9092 environment: KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka0:9092 KAFKA_LISTENERS: PLAINTEXT://kafka0:9092 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_BROKER_ID: 0 volumes: - /data/kafka0/data:/data - /data/kafka0/log:/datalog networks: default: ipv4_address: 172.22.0.12 kafka1: image: wurstmeister/kafka depends_on: - zookeeper container_name: kafka1 ports: - 9093:9093 environment: KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9093 KAFKA_LISTENERS: PLAINTEXT://kafka1:9093 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_BROKER_ID: 1 volumes: - /data/kafka1/data:/data - /data/kafka1/log:/datalog networks: default: ipv4_address: 172.22.0.13 kafka2: image: wurstmeister/kafka depends_on: - zookeeper container_name: kafka2 ports: - 9094:9094 environment: KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9094 KAFKA_LISTENERS: PLAINTEXT://kafka2:9094 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_BROKER_ID: 2 volumes: - /data/kafka2/data:/data - /data/kafka2/log:/datalog networks: default: ipv4_address: 172.22.0.14 kafka-manager: image: sheepkiller/kafka-manager:latest restart: unless-stopped container_name: kafka-manager hostname: kafka-manager ports: - "9000:9000" links: # 连接本compose文件创建的container - kafka0 - kafka1 - kafka2 external_links: # 连接本compose文件以外的container - zookeeper environment: ZK_HOSTS:172.17.0.2:2181 ## 修改:宿主机IP TZ: CST-8 networks: default: external: name: zookeeper_kafka
docker network create --subnet 172.22.0.0/16 --gateway 172.22.0.1 zookeeper_kafka
docker-compose -f docker-compose.yaml up -d
cd /opt/kafka_2.13-2.7.0/bin/
./kafka-topics.sh --create --topic chat --partitions 5 --zookeeper 172.17.0.2:2181 --replication-factor 3
./kafka-console-producer.sh --broker-list kafka0:9092 --topic chat
开启另一个shell界面进入kafka2容器并执行下列命令开启消费者
./kafka-console-consumer.sh --bootstrap-server kafka2:9094 --topic chat --from-beginning
回到生产者shell输入消息,看消费者shell是否会出现同样的消息,如果能够出现说明kafka集群搭建正常。
标签:浏览器 文件 address 管理 topic cluster less ESS div
原文地址:https://www.cnblogs.com/user-sunli/p/14636591.html