Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Run every time you login or update .bash_profile
export KAFKA_HOME=/usr/hdp/2.5.0.0-1245/kafka
export PATH=$PATH:$KAFKA_HOME/bin
# Create topics
kafka-topics.sh --create \
--zookeeper nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181 \
--replication-factor 1 \
--partitions 1 \
--topic kafkadg
# List all topics
kafka-topics.sh --list \
--zookeeper nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181
# List one topic
kafka-topics.sh --list \
--zookeeper nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181 \
--topic kafkadg
kafka-topics.sh --delete \
--zookeeper nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181 \
--topic testdg
# Command to produce messages, start typing after running this kakfa-console-producer command
# The messages will be stored in topic kafkadg on the host where brokers are running
kafka-console-producer.sh \
--broker-list nn01.itversity.com:6667,nn02.itversity.com:6667,rm01.itversity.com:6667 \
--topic kafkadg
# Open another shell and then run kafka-console-consumer command to see streaming messages
kafka-console-consumer.sh \
--bootstrap-server nn01.itversity.com:6667,nn02.itversity.com:6667,rm01.itversity.com:6667 \
--zookeeper nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181 \
--topic kafkadg \
--from-beginning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment