一、服务器:
节点1:10.1.1.165
节点2:10.1.1.164
节点3:10.1.1.169
二、添加环境地址解析
vim /etc/hosts
kafka1 10.1.1.165
kafka2 10.1.1.164
kafka3 10.1.1.169
三、节点配置
节点1
version: "3"
services:kafka1:image: 'bitnami/kafka:3.3.1'container_name: kafka11restart: alwaysuser: rootports:- 9192:9092- 9193:9093environment:- KAFKA_ENABLE_KRAFT=yes- KAFKA_CFG_PROCESS_ROLES=broker,controller- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT- KAFKA_KRAFT_CLUSTER_ID=xxxxxxxxxxxxxxxxxxxxxx- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka1:9193,2@kafka2:9293,3@kafka3:9393- ALLOW_PLAINTEXT_LISTENER=yes- KAFKA_HEAP_OPTS=-Xmx1024M -Xms512M - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.1.1.165:9192- KAFKA_BROKER_ID=1- KAFKA_CFG_NODE_ID=1- TZ=Asia/Shanghaivolumes:- /kafka/kraft:/bitnami/kafka- /etc/localtime:/etc/localtime:ro- /etc/hosts:/etc/hostskafka-ui:image: provectuslabs/kafka-ui:latest# network_mode: heilansc-productcontainer_name: kafka-uirestart: alwaysports:- 9091:8080volumes:- /etc/localtime:/etc/localtime- /etc/hosts:/etc/hostsenvironment:# 集群名称- KAFKA_CLUSTERS_0_NAME=local# 集群地址- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka1:9192,kafka2:9292,kafka3:9392
networks:default:external: truename: product
节点2
version: "3"
services:kafka2:image: 'bitnami/kafka:3.3.1'container_name: kafka22restart: alwaysuser: rootports:- 9292:9092- 9293:9093environment:- KAFKA_ENABLE_KRAFT=yes- KAFKA_CFG_PROCESS_ROLES=broker,controller- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT- KAFKA_KRAFT_CLUSTER_ID=xxxxxxxxxxxxxxxxxxxxxx- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka1:9193,2@kafka2:9293,3@kafka3:9393- ALLOW_PLAINTEXT_LISTENER=yes- KAFKA_HEAP_OPTS=-Xmx1024M -Xms512M - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.1.1.164:9292- KAFKA_BROKER_ID=2- KAFKA_CFG_NODE_ID=2- TZ=Asia/Shanghaivolumes:- /kafka/kraft:/bitnami/kafka- /etc/localtime:/etc/localtime:ro- /etc/hosts:/etc/hosts
networks:default:external: truename: product
节点3
version: "3"
services:kafka3:image: 'bitnami/kafka:3.3.1'container_name: kafka33restart: alwaysuser: rootports:- 9392:9092- 9393:9093environment:- KAFKA_ENABLE_KRAFT=yes- KAFKA_CFG_PROCESS_ROLES=broker,controller- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT- KAFKA_KRAFT_CLUSTER_ID=xxxxxxxxxxxxxxxxxxxxxx- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka1:9193,2@kafka2:9293,3@kafka3:9393- ALLOW_PLAINTEXT_LISTENER=yes- KAFKA_HEAP_OPTS=-Xmx1024M -Xms512M - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.1.1.169:9392- KAFKA_BROKER_ID=3- KAFKA_CFG_NODE_ID=3- TZ=Asia/Shanghaivolumes:- /kafka/kraft:/bitnami/kafka- /etc/localtime:/etc/localtime:ro- /etc/hosts:/etc/hosts
networks:default:external: truename: product