Monday, June 26, 2023

Docker Compose ve Kafka - bitnami

Exporter Kullanan
Açıklaması şöyle
For Kafka Exporter, we use the Bitnami image directly (docker.io/bitnami/kafka-exporter:1.3.1-debian-10-r64).

For JMX Exporter, we also use the Bitnami image directly (docker.io/bitnami/jmx-exporter:0.16.1-debian-10-r17).

Zookeeper Kullanmayan
KAFKA_ENABLE_KRAFT=yes yapmak gerekir
Örnek
Şöyle yaparız. Burada zookeeper yerine kraft kullanılıyor
version: "3"
services: kafka: image: 'bitnami/kafka:latest' volumes: - my-vol:/app/myapp ports: - '9092:9092' 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_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 - KAFKA_BROKER_ID=1 - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@127.0.0.1:9093 - ALLOW_PLAINTEXT_LISTENER=yes volumes: my-vol: external: true
Örnek
Şöyle yaparız
services:
  kafka1:
    image: bitnami/kafka:latest
    networks:
      - kafka-cluster
    ports:
      - '9094:9094'
    environment:
    - ALLOW_PLAINTEXT_LISTENER=yes
    - KAFKA_CFG_NODE_ID=1
    - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka1:9093,2@kafka3:9093,3@kafka3:9093
    - KAFKA_KRAFT_CLUSTER_ID=abcdefghijklmnopqrstuv
    - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
    - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka1:9092,EXTERNAL://localhost:9094
    - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
    volumes:
      - ./kafka/kafka1/kafka:/bitnami/kafka
  kafka2:
    ...
  kafka3:
..
kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:latest
    depends_on:
      - kafka1
      - kafka2
      - kafka3
    networks:
      - kafka-cluster
    ports:
      - "8080:8080"
    environment:
      KAFKA_CLUSTERS_0_NAME: local
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka1:9092,kafka2:9092,kafka3:9092

networks:
  kafka-cluster:
    driver: bridge

Zookeper Kullanan
Image olarak
bitnami/zookeeper:3
bitnami/kafka:2
kullanılır
Örnek
Şöyle yaparız
version: '3.3'
services:
  zookeeper:
    image: 'bitnami/zookeeper:3'
    ports:
      - '2181:2181'
    volumes:
      - 'zookeeper_data:/bitnami'
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    image: 'bitnami/kafka:2'
    ports:
      - '9092:9092'
      - '29092:29092'
    volumes:
      - 'kafka_data:/bitnami'
    environment:
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,PLAINTEXT_HOST://:29092
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
    depends_on:
      - zookeeper
    
volumes:
    zookeeper_data:
        driver: local
    kafka_data:
        driver: local

No comments:

Post a Comment

kafka-consumer-groups.sh komutu

Giriş Bir topic'i dinleyen consumer'ları gösterir. Aynı topic'i dinleyen consumer group'ları olabilir. Her topic farklı part...