Skip to content

Instantly share code, notes, and snippets.

@centum
Created May 21, 2020 13:16
Show Gist options
  • Save centum/ee02bffe7446490d7782b5af89478f25 to your computer and use it in GitHub Desktop.
Save centum/ee02bffe7446490d7782b5af89478f25 to your computer and use it in GitHub Desktop.
Kafka commands
# Install Java
brew tap homebrew/cask-versions
brew tap adoptopenjdk/openjdk
brew cask install java
java --version
# Get Kafka
wget https://www2.apache.paket.ua/kafka/2.5.0/kafka_2.12-2.5.0.tgz
# Unpack
tar xvf kafka_2.12-2.5.0.tgz
cd kafka_2.12-2.5.0/bin
# List the groups
./kafka-consumer-groups.sh --bootstrap-server <host:port> --list
# List the topics to which the group is subscribed
./kafka-consumer-groups.sh --bootstrap-server <host:port> --group <group> --describe
# Reset the consumer offset for a topic (preview)
./kafka-consumer-groups.sh --bootstrap-server <host:port> --group <group> --topic <topic[:partiotion]> --reset-offsets --to-earliest
# Reset the consumer offset for a topic
./kafka-consumer-groups.sh --bootstrap-server <host:port> --group <group> --topic <topic[:partiotion]> --reset-offsets --to-earliest --execute
# * The consumer group must have no running instance when performing the reset. Otherwise the reset will be rejected.
# * There are many other resetting options, run kafka-consumer-groups for details
# --shift-by <positive_or_negative_integer>
# --to-current
# --to-latest
# --to-offset <offset_integer>
# --to-datetime <datetime_string>
# --by-duration <duration_string>
# * The command also provides an option to reset offsets for all topics the consumer group subscribes to: --all-topics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment