From 2a3eb5b1310b356b972056cf208491f6b59e3def Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 24 Oct 2022 17:33:02 +0200 Subject: [PATCH] Setup auf KRAFT umgestellt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Der Zookeeper wird dann nicht mehr benötigt. * Broker-Images auf `bitnami/kafka:3.3.1` umgestellt, da die Confluent- Images den KRAFT-Modus noch nicht unterstützen. * README.sh an die Änderungen angepasst. --- README.sh | 2 +- docker-compose.yml | 76 ++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/README.sh b/README.sh index e96245a..f5bd509 100755 --- a/README.sh +++ b/README.sh @@ -10,7 +10,7 @@ then fi docker-compose rm -svf consumer -docker-compose up -d zookeeper kafka-1 kafka-2 kafka-3 cli +docker-compose up -d kafka-1 kafka-2 kafka-3 cli if [[ $(docker image ls -q $IMAGE) == "" || diff --git a/docker-compose.yml b/docker-compose.yml index de4905d..e7d0413 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,39 +1,40 @@ version: '3.2' services: - zookeeper: - image: confluentinc/cp-zookeeper:7.1.3 - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ports: - - 2181:2181 - kafka-1: - image: confluentinc/cp-kafka:7.1.3 + image: bitnami/kafka:3.3.1 environment: + KAFKA_ENABLE_KRAFT: 'yes' + KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw + KAFKA_CFG_PROCESS_ROLES: broker,controller + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_LISTENERS: BROKER://:9092, CONTROLLER://:9093, LOCALHOST://:9081 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT + KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-1:9092, LOCALHOST://localhost:9081 KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9081 - KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-1:9092, LOCALHOST://localhost:9081 - KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9093,2@kafka-2:9093,3@kafka-3:9093 + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER + KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9081:9081 - depends_on: - - zookeeper kafka-2: - image: confluentinc/cp-kafka:7.1.3 + image: bitnami/kafka:3.3.1 environment: + KAFKA_ENABLE_KRAFT: 'yes' + KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw + KAFKA_CFG_PROCESS_ROLES: broker,controller + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_LISTENERS: BROKER://:9092, CONTROLLER://:9093, LOCALHOST://:9082 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT + KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-2:9092, LOCALHOST://localhost:9082 KAFKA_BROKER_ID: 2 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9082 - KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-2:9092, LOCALHOST://localhost:9082 - KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9093,2@kafka-2:9093,3@kafka-3:9093 + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER + KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9092:9082 - 9082:9082 @@ -41,24 +42,25 @@ services: default: aliases: - kafka - depends_on: - - zookeeper kafka-3: - image: confluentinc/cp-kafka:7.1.3 + image: bitnami/kafka:3.3.1 environment: + KAFKA_ENABLE_KRAFT: 'yes' + KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw + KAFKA_CFG_PROCESS_ROLES: broker,controller + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_LISTENERS: BROKER://:9092, CONTROLLER://:9093, LOCALHOST://:9083 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT + KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-3:9092, LOCALHOST://localhost:9083 KAFKA_BROKER_ID: 3 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9083 - KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka-3:9092, LOCALHOST://localhost:9083 - KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9093,2@kafka-2:9093,3@kafka-3:9093 + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER + KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9083:9083 - depends_on: - - zookeeper setup: -- 2.20.1