Skip to content

Instantly share code, notes, and snippets.

@singhabhinav
Last active February 19, 2021 11:49
Show Gist options
  • Save singhabhinav/1003a2a47318d85a222b4f51c3f79cf7 to your computer and use it in GitHub Desktop.
Save singhabhinav/1003a2a47318d85a222b4f51c3f79cf7 to your computer and use it in GitHub Desktop.
Kafka hands-on on CloudxLab
# Include Kafka binaries in the path
export PATH=$PATH:/usr/hdp/current/kafka-broker/bin
# Create the topic
# Replace localhost with the hostname of node where zookeeper server is running.
# Replace test with your topic name
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
# Check if topic is created
kafka-topics.sh --list --zookeeper localhost:2181
# Produce
# find the ip address of any broker from zookeeper-client using command get /brokers/ids/0
# test is a topicname here. Replace test with some name specific to your username like abhinav9884_test
# Replace localhost with the hostname of broker
# Replace test with your topic name
kafka-console-producer.sh --broker-list localhost:6667 --topic test
# Push messages to topic, type "my first kafka topic"
# Test if producer is working by consuming messages in another terminal
# Replace test with your topic name
kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment