Bootstrap

docker-compose部署kafka 3.3.1 kraft

一、服务器:

节点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: kafka11
    restart: always
    user: root
    ports:
      - 9192:9092
      - 9193:9093
    environment:
      - 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/Shanghai
    volumes:
      - /kafka/kraft:/bitnami/kafka
      - /etc/localtime:/etc/localtime:ro
      - /etc/hosts:/etc/hosts
  kafka-ui:
    image: provectuslabs/kafka-ui:latest
    #    network_mode: heilansc-product
    container_name: kafka-ui
    restart: always
    ports:
      - 9091:8080
    volumes:
      - /etc/localtime:/etc/localtime
      - /etc/hosts:/etc/hosts
    environment:
      # 集群名称
      - KAFKA_CLUSTERS_0_NAME=local
      # 集群地址
      - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka1:9192,kafka2:9292,kafka3:9392
networks:
  default:
    external: true
    name: product

节点2

version: "3"
services:
  kafka2:
    image: 'bitnami/kafka:3.3.1'
    container_name: kafka22
    restart: always
    user: root
    ports:
      - 9292:9092
      - 9293:9093
    environment:
      - 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/Shanghai
    volumes:
      - /kafka/kraft:/bitnami/kafka
      - /etc/localtime:/etc/localtime:ro
      - /etc/hosts:/etc/hosts
networks:
  default:
    external: true
    name: product

节点3

version: "3"
services:
  kafka3:
    image: 'bitnami/kafka:3.3.1'
    container_name: kafka33
    restart: always
    user: root
    ports:
      - 9392:9092
      - 9393:9093
    environment:
      - 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/Shanghai
    volumes:
      - /kafka/kraft:/bitnami/kafka
      - /etc/localtime:/etc/localtime:ro
      - /etc/hosts:/etc/hosts
networks:
  default:
    external: true
    name: product

;