Kafka Useful Commands

Install Kafka on Mac locally

brew install --cask java
brew install kafka

Run Zookeeper and Kafka

brew services start zookeeper
brew service start kafka

Create topic

kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test-sk

Run producer console

kafka-console-producer --broker-list localhost:9092 --topic test-sk

Run consumer console

kafka-console-consumer --bootstrap-server localhost:9092 --topic test-sk --from-beginning

List Kafka topics

kafka-topics --list --zookeeper localhost:2181

Describe a topic

kafka-topics --describe --zookeeper localhost:2181 --topic test-sk

To update the configuration for a Kafka topic

kafka-topics --alter --zookeeper localhost:2181 --topic test-sk --config retention.ms=1000

To delete configuration in a topic

kafka-topics --alter --zookeeper localhost:2181 --topic test-sk --delete-config retention.ms

To check the beginning and ending offset

kafka-run-class kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test-sk --time -1

Kafka delete records in partitions from earliest offset to specific offset

kafka-delete-records --bootstrap-server localhost:9092 --offset-json-file offset-json.json
{  "partitions": [    {      "topic": "test-sk",      "partition": 0,      "offset": -1    }  ],  "version": 1}

--

--

--

Write anything comes into mind. Software Engineering. Computer Programing. Philosophy. Everything about life.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

UPDATE A NODE IN LINKLIST

Overview of Odoo V15 Maintenance Module

1 min guide to iOS development best practices in 2022

1 min guide to learn iOS development best practices in 2022

Data Structures and Algorithms

Integration of Apache httpd with GitHub, Docker and Jenkins

9 Ways to Increase Productivity when Coding from Home

Create AMIs through AWS CloudFormation and use them to create the infrastructure within the same…

Argo Tunnel + DC/OS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Crown S.

Crown S.

Write anything comes into mind. Software Engineering. Computer Programing. Philosophy. Everything about life.

More from Medium

How to set up Keycloak with Docker and PostgreSQL

Kafka Cluster on Docker Compose

Running a local Kafka cluster using Docker Compose

Introduction to docker, containers, docker compose, dockerfile

docker, container, docker compose, virtual machine