安装环境:ubuntu20.04;网络-桥接模式;已安装docker-compose
本文搭建集群为无认证方式
一:docker-compose搭建kafka集群
1.创建kafka目录并进入此目录
2.创建docker-compose.yaml
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
restart: always
ports:
- "2181:2181"
kafka1:
image: wurstmeister/kafka
container_name: kafka1
restart: always
ports:
- "9092:9092"
environment:
- KAFKA_BROKER_ID=0
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://虚拟机ip:9092
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092
kafka2:
image: wurstmeister/kafka
container_name: kafka2
restart: always
ports:
- "9093:9093"
environment: