Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Kafka] Kafka Console Producer CLI.

Posted on January 31, 2022February 27, 2022 By nim No Comments on [Kafka] Kafka Console Producer CLI.

Producers

• Producers write data to topics (which is made of partitions)
• Producers automatically know to which broker and partition to write to
• In case of Broker failures, Producers will automatically recover

• Producers can choose to receive acknowledgment of data writes:
• acks=0: Producer won’t wait for acknowledgment (possible data loss)
• acks=1: Producer will wait for leader acknowledgment (limited data loss)
• acks=all: Leader + replicas acknowledgment (no data loss)

Producers: Message keys

  • Producers can choose to send a key with the message (string, number, etc..)
  • If key=null, data is sent round robin (broker 101 then 102 then 103…)
  • If a key is sent, then all messages for that key will always go to the same partition
  • A key is basically sent if you need message ordering for a specific field (ex: truck_id)

kafka-console-producer.sh

chúng ta list ra xem chúng ta đã tạo topics nào trước đó?

kafka-topics.sh  --bootstrap-server localhost:9092 --list
kafka-console-producer.sh  --bootstrap-server localhost:9092 --topic first-topic
thực hiện ghi data vào topic “first-topic”

Chọn receive acknowledgment of data writes

kafka-console-producer.sh  --bootstrap-server localhost:9092 --topic first-topic --producer-property acks=all

Nếu topic chưa được tạo trước đó thì sao?

kafka-console-producer.sh  --bootstrap-server localhost:9092 --topic new-topic

Nếu topic chưa được tạo trước đó mà producer vẫn tạo lệnh write vào new topic đó. thì kafka sẽ văng warning: WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 3 : {new-topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) và thực create topic đó

kafka-topics.sh --bootstrap-server localhost:9092 --list

chúng show thông tin của topic “new-topic” sem có j cool

kafka-topics.sh  --bootstrap-server localhost:9092 --topic new-topic --describe
các bạn có thể thấy là chỉ có 1 partition

Nếu bạn muốn thay đôi số partition đối với hành vi tạo tự động các topic thì

grep -v "^#" /root/kafka/config/server.properties
bạn change field “num.partitions“
Apache Kafka, Kafka, Log, Monitor & Tracing

Post navigation

Previous Post: [Kafka] Kafka Topics CLI
Next Post: [web] Chuyển ảnh sang text

More Related Articles

[Monitoring] Understand percentiles in monitoring. Grafana
[Kafka-connect] research on Kafka Connect Source and demo watch the changing file. Apache Kafka
[Kibana-ELK] Installing and Seting a Kibana For ELK ELK
[Grafana] Graph(old) – Hiện thị chart và table thông tin Grafana
[Kafka-connect] Single Message Transform: lesson 1 – InsertField in Sink Apache Kafka
[error] Solve elasticsearch error Limit of total fields [1000] in index [xxx] ELK

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ May 8, 2025
  • [Azure] Insufficient regional vcpu quota left May 8, 2025
  • [WordPress] How to add a Dynamic watermark on WordPress. May 6, 2025
  • [vnet/Azure] VNet provisioning via Terraform. April 28, 2025
  • [tracetcp] How to perform a tracert command using a specific port. April 3, 2025

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.