Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Kafka command-line tools (examples in OSX)

Kafka command line tools

List (not complete)

  • - starting Zookeeper
  • - start Kafka
  • - manage topics in Kafka
  • - script for sending messages to Kafka topic
  • - script for consuming messages from Kafka topic
  • - script for running different tools (list of tools can be found here)

Example use

The following paths are standard paths on OSX when Kafka is installed via Brew. At the time of writing current Kafka version is All the commands are executed from within /usr/local/Cellar/kafka/

Ramp up Zookeeper:

./ ../config/

Ramp up Kafka:

./ ../config/

Create a topic

./ --create  --topic example-topic --zookeeper localhost:2181 --partitions 1 --replication-factor 1
./ --list

Create a consumer

./ --topic example-topic --from-beginning --bootstrap-server localhost:9092

Produce message

./ --topic example-topic --broker-list localhost:9092
> {"event":"EXAMPLE", "data":{"id":"123", "name":"Piotr"}, "metadata":{"version":"001"}, "timestamp":"2017-11-05T00:00:00Z" }

Check offsets

./ --topic example-topic --zookeeper --group example-group
Copy link

knappt commented Mar 29, 2022

For create a topic,
--zookeeper is deprecated
use --bootstrap-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment