x新建 root/kafka 目录 放入三个yml 文件
1 zk.yml
创建ZOOKEEPER集群
version: '3.4' services: zoo1: image: zookeeper:3.4 restart: always hostname: zoo1 container_name: zoo1 ports: - 2184:2181 volumes: - "/clay/volume/zkcluster/zoo1/data:/data" - "/clay/volume/zkcluster/zoo1/datalog:/datalog" environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 networks: kafka: ipv4_address: 172.19.0.11 zoo2: image: zookeeper:3.4 restart: always hostname: zoo2 container_name: zoo2 ports: - 2185:2181 volumes: - "/clay/volume/zkcluster/zoo2/data:/data" - "/clay/volume/zkcluster/zoo2/datalog:/datalog" environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zoo3:2888:3888 networks: kafka: ipv4_address: 172.19.0.12 zoo3: image: zookeeper:3.4 restart: always hostname: zoo3 container_name: zoo3 ports: - 2186:2181 volumes: - "/clay/volume/zkcluster/zoo3/data:/data" - "/clay/volume/zkcluster/zoo3/datalog:/datalog" environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=0.0.0.0:2888:3888 networks: kafka: ipv4_address: 172.19.0.13 networks: kafka: external: name: kafka
2 kafka.yml
KAFKA集群构建
version: '3.4' services: kafka1: image: wurstmeister/kafka restart: always hostname: kafka1 container_name: kafka1 privileged: true ports: - 9092:9092 environment: KAFKA_ADVERTISED_HOST_NAME: kafka1 KAFKA_LISTENERS: PLAINTEXT://kafka1:9092 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.3.204:9092 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181 volumes: - /clay/volume/kfkluster/kafka1/logs:/kafka external_links: - zoo1 - zoo2 - zoo3 networks: kafka: ipv4_address: 172.19.0.14 kafka2: image: wurstmeister/kafka restart: always hostname: kafka2 container_name: kafka2 privileged: true ports: - 9093:9093 environment: KAFKA_ADVERTISED_HOST_NAME: kafka2 KAFKA_LISTENERS: PLAINTEXT://kafka2:9093 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.3.204:9093 KAFKA_ADVERTISED_PORT: 9093 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181 volumes: - /clay/volume/kfkluster/kafka2/logs:/kafka external_links: - zoo1 - zoo2 - zoo3 networks: kafka: ipv4_address: 172.19.0.15 kafka3: image: wurstmeister/kafka restart: always hostname: kafka3 container_name: kafka3 privileged: true ports: - 9094:9094 environment: KAFKA_ADVERTISED_HOST_NAME: kafka3 KAFKA_LISTENERS: PLAINTEXT://kafka3:9094 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.3.204:9094 KAFKA_ADVERTISED_PORT: 9094 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181 volumes: - /clay/volume/kfkluster/kafka3/logs:/kafka external_links: - zoo1 - zoo2 - zoo3 networks: kafka: ipv4_address: 172.19.0.16 networks: kafka: external: name: kafka
3 kafkamanage.yml
KAFKA-MANAGER工具
version: "3.4" services: kafka-manager: image: sheepkiller/kafka-manager:latest restart: always container_name: kafka-manager hostname: kafka-manager ports: - 9000:9000 environment: ZK_HOSTS: zoo1:2181,zoo2:2181,zoo3:2181 KAFKA_BROKERS: kafka1:9092,kafka2:9092,kafka3:9092 APPLICATION_SECRET: letmein KM_ARGS: -Djava.net.preferIPv4Stack=true networks: kafka: ipv4_address: 172.19.0.17 networks: kafka: external: name: kafka
启动 ~~
美滋滋~~~~