From d1b5b725743e48da9de584ad55d9d8f3b37557a1 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 2 Apr 2022 23:57:37 +0200 Subject: [PATCH] =?utf8?q?Basis-Setup=20f=C3=BCr=20die=20acks-=C3=9Cbungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.sh | 13 +++++++++++-- docker-compose.yml | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/README.sh b/README.sh index f651155..a60804a 100755 --- a/README.sh +++ b/README.sh @@ -9,7 +9,7 @@ then exit fi -docker-compose up -d zookeeper kafka cli +docker-compose up -d zookeeper kafka-1 kafka-2 kafka-3 cli if [[ $(docker image ls -q $IMAGE) == "" || @@ -23,11 +23,20 @@ else fi echo "Waiting for the Kafka-Cluster to become ready..." -docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1 +docker-compose exec cli cub kafka-ready -b kafka:9092 3 60 > /dev/null 2>&1 || exit 1 docker-compose up setup docker-compose up -d sleep 15 +echo foo | http -v :8080/foo +docker-compose kill -s 9 kafka-1 +sleep 5 +echo bar | http -v :8080/bar +docker-compose kill -s 9 kafka-3 +sleep 5 +echo foobar | http -v :8080/foobar + +http -v :8081/seen docker-compose stop producer consumer diff --git a/docker-compose.yml b/docker-compose.yml index 336c459..2747529 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,20 +7,56 @@ services: ports: - 2181:2181 - kafka: + kafka-1: image: confluentinc/cp-kafka:7.0.2 environment: 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" + ports: + - 9081:9081 + depends_on: + - zookeeper + + kafka-2: + image: confluentinc/cp-kafka:7.0.2 + environment: + KAFKA_BROKER_ID: 2 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9082 - KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka:9092, LOCALHOST://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: 1 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" ports: - 9092:9082 - 9082:9082 + networks: + default: + aliases: + - kafka + depends_on: + - zookeeper + + kafka-3: + image: confluentinc/cp-kafka:7.0.2 + environment: + 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" + ports: + - 9083:9083 depends_on: - zookeeper @@ -29,7 +65,8 @@ services: command: > bash -c " kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test - kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 + kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 1 --replication-factor 3 --config min.insync.replicas=2 + kafka-topics --bootstrap-server kafka:9092 --describe --topic test " cli: -- 2.20.1