Skip to content

Instantly share code, notes, and snippets.

@shabbirdwd53
Created August 20, 2020 12:03
Show Gist options
  • Save shabbirdwd53/d3b531d61379068da26d16487e37af34 to your computer and use it in GitHub Desktop.
Save shabbirdwd53/d3b531d61379068da26d16487e37af34 to your computer and use it in GitHub Desktop.
Kakfa Server installation using Docker
version: "3"
services:
zookeeper:
image: 'bitnami/zookeeper:latest'
container_name: zookeeper
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
image: 'bitnami/kafka:latest'
container_name: kakfa
ports:
- '9092:9092'
environment:
- KAFKA_BROKER_ID=1
- KAFKA_LISTENERS=PLAINTEXT://:9092
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper
@Srthak100
Copy link

What should I do if I want to change the replication factor and have multiple brokers?

@edercarloscosta
Copy link

@Srthak100

An idea:

kafka-server1:
image: 'bitnami/kafka:latest'
conainer_name: kakfa_server1
ports:
- '9092:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper

kafka-server2:
image: 'bitnami/kafka:latest'
container_name: kafka-server2:
ports:
- '9093:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9093
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper

You can go deeper on container and works internally over each point if you wish.
ex:

  1. Working with container (n)

docker exec -it kafka-server1 /bin/sh

  1. Navigate into conainter directory

cd /opt/kafka/bin

  1. Creating a 'topic' with partition/replication you want to:

kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partition 1 --topic

cheers,

@abhishekpcnair
Copy link

This setup says, no broker found when i try to add CMAK manager

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