Topic management and operations
kafka-topics --bootstrap-server localhost:9092 --list
kafka-topics --bootstrap-server localhost:9092 --describe --topic my-topic
kafka-topics --bootstrap-server localhost:9092 --create --topic my-topic --partitions 3 --replication-factor 1
Consume messages from topics
kafka-console-consumer --bootstrap-server localhost:9092 --topic my-topic --from-beginning
kafka-console-consumer --bootstrap-server localhost:9092 --topic my-topic --group my-consumer-group
kafka-console-consumer --bootstrap-server localhost:9092 --topic my-topic --property print.key=true --property key.separator=:
Produce messages to topics
kafka-console-producer --bootstrap-server localhost:9092 --topic my-topic
kafka-console-producer --bootstrap-server localhost:9092 --topic my-topic
kafka-console-producer --bootstrap-server localhost:9092 --topic my-topic --property parse.key=true --property key.separator=:
Consumer group management
kafka-consumer-groups --bootstrap-server localhost:9092 --list
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group my-consumer-group
kafka-consumer-groups --bootstrap-server localhost:9092 --reset-offsets --group my-consumer-group --topic my-topic --to-earliest --execute
kafka-get-offsets --bootstrap-server localhost:9092 --topic my-topic
kafka-configs --bootstrap-server localhost:9092 --entity-type topics --entity-name my-topic --describe
kafka-leader-election --bootstrap-server localhost:9092 --election-type PREFERRED --all-topic-partitions
kafka-producer-perf-test --topic my-topic --num-records 1000000 --record-size 1000 --throughput 10000 --producer-props bootstrap.servers=localhost:9092
kafka-consumer-perf-test --bootstrap-server localhost:9092 --topic my-topic --messages 1000000
Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. It is designed for high-throughput, fault-tolerant handling of real-time data feeds. Kafka is used for building real-time data pipelines and streaming applications. It combines the benefits of traditional messaging systems with the scalability and fault tolerance of distributed systems.
Kafka Tools are command-line utilities that come with Apache Kafka for managing and monitoring Kafka clusters. These tools provide functionality for topic management, consumer group operations, performance testing, and cluster administration. They are essential for developers and operators working with Kafka clusters.
--bootstrap-server {bootstrap-server}
becomes --bootstrap-server localhost:9092
when you enter "localhost:9092" in the bootstrap server field.kafka-[tool] --bootstrap-server [server] [options]
kafka-topics --bootstrap-server [server] --[action] --topic [topic]
kafka-console-consumer --bootstrap-server [server] --topic [topic]
kafka-console-producer --bootstrap-server [server] --topic [topic]
kafka-consumer-groups --bootstrap-server [server] --group [group]
kafka-[producer|consumer]-perf-test --bootstrap-server [server] --topic [topic]
--from-beginning
to read all messages from the start--property print.timestamp=true
to see message timestamps--property key.separator=:
for key-value message handlingkafka-consumer-groups --describe