Skip to content

Instantly share code, notes, and snippets.

@prashanta
Last active July 22, 2022 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save prashanta/bc5dd3c75070ae8bb89cdf0c6449d569 to your computer and use it in GitHub Desktop.
Save prashanta/bc5dd3c75070ae8bb89cdf0c6449d569 to your computer and use it in GitHub Desktop.
Apache Kafka - Useful Commands
Action Command
START ZOOKEEPER AND KAFKA BROKER ./bin/kafka-server-start.sh -daemon ./config/server.properties

./bin/zookeeper-server-start.sh --deamon ./config/zookeeper.properties
CREATE NEW TOPIC ./bin/kafka-topics.sh --create --topic test --partitions 3  --bootstrap-server localhost:9092
GET TOPIC INFO ./bin/kafka-topics.sh --list --bootstrap-server localhost:9092 

./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092
GET LIST OF CONSUMER GROUPS ./bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092
GET CONSUMER GROUP INFORMATION (second example is for Azure Event Hub): ./bin/kafka-consumer-groups.bat --bootstrap-server localhost:9092 --group test --describe

./bin/kafka-consumer-groups.sh --command-config config/consumer.properties --bootstrap-server mynamespace.servicebus.windows.net:9093 --describe --group P02
GET TOPIC PARTITION OFFSETS ./bin/kafka-run-class.bat kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic telemetry

./bin/kafka-run-class.bat kafka.tools.DumpLogSegments --deep-iteration --print-data-log --files /tmp/kafka-logs/telemetry-2/00000000000000000000.log
KAFKA PRODUCER CONSOLE ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
KAFKA CONSUMER CONSOLE ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic telemetry --property print.key=true --property print.value=true --partition 1
KAFKA CONSUMER CONSOLE
Get Config from file
./bin/kafka-console-consumer.sh --consumer.config ./config/consumer.properties --bootstrap-server localhost:9092 --from-beginning --topic telemetry --property print.key=true --property print.value=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment