Created
June 12, 2020 11:45
-
-
Save PardhuMadipalli/65c888243a192421f5a47e9c8ab14a38 to your computer and use it in GitHub Desktop.
Simple aliases and functions for Apache Kafka commands
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
export KAFKA_HOME=<kafka installation directory> | |
# Start Kafka server | |
alias startKafka='$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties' | |
# List of topics with zookeeper of localhost | |
alias topics='$KAFKA_HOME/bin/kafka-topics.sh --list --zookeeper localhost:2181' | |
# Create a new cosnumer that reads from the starting from the topic. It uses localhost kafka broker. | |
# Example: readtopic topicName | |
readtopic () | |
{ | |
$KAFKA_HOME/bin/kafka-console-consumer.sh --topic $1 --from-beginning --bootstrap-server localhost:9092 | |
} | |
# use this to delete a topic | |
# Example: deletetopic topicName | |
deletetopic() | |
{ | |
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic $1 | |
} | |
# Create a new cosnumer that reads from the current record of the topic. It uses localhost kafka broker. | |
# Example: readtopic topicName | |
readtopicnow(){ | |
$KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment