Last active
January 30, 2019 09:49
-
-
Save kavimaluskam/6767930c25274a81cf07260f019c6b6c to your computer and use it in GitHub Desktop.
Cheat sheet for Kafka Topic CRUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter Kafka Shell Client | |
make kafka-shell | |
# Assign testing topic name in variable | |
TOPIC=test | |
# Describe all topic | |
kafka-topics --describe --zookeeper $ZK | |
# Create topic | |
kafka-topics --create --topic $TOPIC --partitions 4 --zookeeper $ZK --replication-factor 2 | |
# Describe partitions, replication, leader brokers for selected topic | |
kafka-topics --describe --zookeeper $ZK --topic $TOPIC | |
# Count the number of messages inside a topic | |
kafka-run-class kafka.tools.GetOffsetShell --broker-list=$BROKERS --topic $TOPIC --time -1 | |
# Update retention policy of a topic | |
# "-1" means forever | |
kafka-configs --zookeeper $ZK --alter --entity-type topics --entity-name $TOPIC --add-config retention.ms=-1 | |
kafka-configs --zookeeper $ZK --alter --entity-type topics --entity-name $TOPIC --add-config retention.bytes=-1 | |
# Delete topics | |
kafka-topics --delete --topic $TOPIC --zookeeper $ZK | |
# Exit Docker when CRUD is done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment