Spread the love

Kafka Topics
List existing topics
bin/kafka-topics.sh –zookeeper localhost:2181 –list

Purge a topic
bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –config retention.ms=1000

… wait a minute …

bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –delete-config retention.ms

Delete a topic
bin/kafka-topics.sh –zookeeper localhost:2181 –delete –topic mytopic

Get the earliest offset still in a topic
bin/kafka-run-class.sh kafka.tools.GetOffsetShell –broker-list localhost:9092 –topic mytopic –time -2

Get the latest offset still in a topic
bin/kafka-run-class.sh kafka.tools.GetOffsetShell –broker-list localhost:9092 –topic mytopic –time -1

Consume messages with the console consumer
bin/kafka-console-consumer.sh –new-consumer –bootstrap-server localhost:9092 –topic mytopic –from-beginning

Get the consumer offsets for a topic
bin/kafka-consumer-offset-checker.sh –zookeeper=localhost:2181 –topic=mytopic –group=my_consumer_group

Read from __consumer_offsets
Add the following property to config/consumer.properties: exclude.internal.topics=false

bin/kafka-console-consumer.sh –consumer.config config/consumer.properties –from-beginning –topic __consumer_offsets –zookeeper localhost:2181 –formatter “kafka.coordinator.GroupMetadataManager\$OffsetsMessageFormatter”

Kafka Consumer Groups
List the consumer groups known to Kafka
bin/kafka-consumer-groups.sh –zookeeper localhost:2181 –list (old api)

bin/kafka-consumer-groups.sh –new-consumer –bootstrap-server localhost:9092 –list (new api)

View the details of a consumer group
bin/kafka-consumer-groups.sh –zookeeper localhost:2181 –describe –group

Getting the last five message of a topic
kafkacat -C -b localhost:9092 -t mytopic -p 0 -o -5 -e

Starting the Zookeeper Shell
bin/zookeeper-shell.sh localhost:2181

Related Posts


What is Apache Maven | Apache Maven complete tutorial from scratch pdf

Spread the love In this post you will learn the complete tutorial of Apache Maven build tool What is Maven ? Apache Maven is a software project management and comprehension tool. Based on the concept
Read more…


Practical Guide for Web Development in 2018

Spread the loveWelcome to my practical guide  for web development in 2018 in terms of  technology and career. Before we start I just want to  mention a few things, you don’t need to learn  everything that
Read more…


Azure Tutorial from Scratch | Introduction to Azure Clouds

Spread the loveIn Azure Tutorial from Scratch, I will give you the in and outs of Azure architecture and also more details on the following DataCenter Network (N/w) services Computes/Virtual Machines/Hosts/Machines PrivateNetwork (n/w) Services In this
Read more…