Skip to content

Instantly share code, notes, and snippets.

@rmoff
Last active March 18, 2024 03:34
Show Gist options
  • Save rmoff/ba6c335367764953e390e273e019c083 to your computer and use it in GitHub Desktop.
Save rmoff/ba6c335367764953e390e273e019c083 to your computer and use it in GitHub Desktop.
Multi-node Kafka cluster (three brokers)
---
version: '3.8'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:5.5.1
ports:
- '32181:32181'
environment:
ZOOKEEPER_CLIENT_PORT: 32181
ZOOKEEPER_TICK_TIME: 2000
kafka-1:
image: confluentinc/cp-kafka:5.5.1
ports:
- '9092:9092'
depends_on:
- zookeeper-1
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:32181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka-1:29092,EXTERNAL://localhost:9092
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 3
kafka-2:
image: confluentinc/cp-kafka:5.5.1
ports:
- '9093:9093'
depends_on:
- zookeeper-1
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:32181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka-2:29093,EXTERNAL://localhost:9093
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 3
kafka-3:
image: confluentinc/cp-kafka:5.5.1
ports:
- '9094:9094'
depends_on:
- zookeeper-1
environment:
KAFKA_BROKER_ID: 3
KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:32181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka-3:29094,EXTERNAL://localhost:9094
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 3
@rmoff
Copy link
Author

rmoff commented Oct 12, 2020

@rmoff
Copy link
Author

rmoff commented Oct 12, 2020

╰─$ docker run --network host --interactive --rm edenhill/kafkacat:1.6.0 -b localhost:9093 -L                                                                                             1 ↵
Metadata for all topics (from broker 2: localhost:9093/2):
 3 brokers:
  broker 2 at localhost:9093
  broker 3 at localhost:9094
  broker 1 at localhost:9092 (controller)
 1 topics:
  topic "__confluent.support.metrics" with 1 partitions:
    partition 0, leader 3, replicas: 3,2,1, isrs: 3,2,1
╰─$ docker run --network tmp_default --interactive --rm edenhill/kafkacat:1.6.0 -b kafka-2:29093 -L
Metadata for all topics (from broker 2: kafka-2:29093/2):
 3 brokers:
  broker 2 at kafka-2:29093
  broker 3 at kafka-3:29094
  broker 1 at kafka-1:29092 (controller)
 1 topics:
  topic "__confluent.support.metrics" with 1 partitions:
    partition 0, leader 3, replicas: 3,2,1, isrs: 3,2,1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment