0% found this document useful (0 votes)
384 views1 page

Kafka Cheat Sheets

This document provides summaries of commonly used Kafka commands for topic management, producer commands, consumer commands, and other commands. Topic management commands allow users to create, describe, list, alter, and delete topics. Producer commands allow sending messages to topics from the console or from files. Consumer commands allow reading messages from topics from the console or in consumer groups. Other commands configure topics, retrieve offsets, and run performance tests.

Uploaded by

Akin Akinmosin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
384 views1 page

Kafka Cheat Sheets

This document provides summaries of commonly used Kafka commands for topic management, producer commands, consumer commands, and other commands. Topic management commands allow users to create, describe, list, alter, and delete topics. Producer commands allow sending messages to topics from the console or from files. Consumer commands allow reading messages from topics from the console or in consumer groups. Other commands configure topics, retrieve offsets, and run performance tests.

Uploaded by

Akin Akinmosin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Here are some Kafka cheat sheets with commonly used commands and their syntax:

Topic management
bin/kafka-topics.sh --create --zookeeper zookeeper_host:port --replication-factor 1
--partitions 1 --topic topic_name - creates a new topic with the specified name,
replication factor, and number of partitions
bin/kafka-topics.sh --describe --zookeeper zookeeper_host:port --topic topic_name -
retrieves information about the specified topic, including its partitions and
replica assignments
bin/kafka-topics.sh --list --zookeeper zookeeper_host:port - lists all topics in
the cluster
bin/kafka-topics.sh --alter --zookeeper zookeeper_host:port --topic topic_name --
partitions 2 - increases the number of partitions in the specified topic to the
specified number
bin/kafka-topics.sh --delete --zookeeper zookeeper_host:port --topic topic_name -
deletes the specified topic
Producer commands
bin/kafka-console-producer.sh --broker-list broker_host:port --topic topic_name -
starts a console producer that sends messages to the specified topic
bin/kafka-console-producer.sh --broker-list broker_host:port --topic topic_name <
input.txt - reads input from a file and sends each line as a message to the
specified topic
Consumer commands
bin/kafka-console-consumer.sh --bootstrap-server broker_host:port --topic
topic_name --from-beginning - starts a console consumer that reads messages from
the specified topic
bin/kafka-console-consumer.sh --bootstrap-server broker_host:port --topic
topic_name --group consumer_group - starts a console consumer that reads messages
from the specified topic and belongs to the specified consumer group
bin/kafka-consumer-groups.sh --bootstrap-server broker_host:port --list - lists all
consumer groups in the cluster
bin/kafka-consumer-groups.sh --bootstrap-server broker_host:port --describe --group
consumer_group - retrieves detailed information about the specified consumer group
Other commands
bin/kafka-topics.sh --zookeeper zookeeper_host:port --alter --config
retention.ms=86400000 --topic topic_name - sets the specified configuration
property for the specified topic
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list broker_host:port --
topic topic_name --time -1 - retrieves the current offset for the specified topic
and partition
bin/kafka-producer-perf-test.sh --topic topic_name --num-records 100000 --record-
size 100 --throughput 1000 --producer-props bootstrap.servers=broker_host:port -
runs a performance test that produces the specified number of records to the
specified topic, each with the specified size and throughput limit
These are just a few examples of the commands available in Kafka. For a more
comprehensive list of commands and their syntax, you can refer to the Kafka
documentation or run the Kafka help command, "bin/kafka-topics.sh --help" for
example, in your terminal.

You might also like