Start Zookeeper
zookeeper-server-start.sh kafka_2.11-2.4.1/config/zookeeper.properties
Start Kafka
kafka-server-start.sh kafka_2.11-2.4.1/config/server.properties
Setup Another Broker
Make copy of server.properties
file in the kafka config folder
Set the broker id = 1
On line 32 uncomment line listeners = url:port and change port to 9093
On line 60 change the log directory
# Start new Broker
kafka-server-start.sh kafka_2.11-2.4.1/config/server1.properties
Create a Topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic stockupdates --if-not-exists
Increase Partitions of a Topic
kafka-topics.sh --zookeeper localhost:2181 --alter --topic my-first-topic --partitions 5
Describe an Topic
kafka-topics.sh --zookeeper localhost:2181 --describe --topic covid
Delete a Topic
kafka-topics.sh --zookeeper localhost:2181 --delete --topic securityalerts
List Topics
kafka-topics.sh --list --zookeeper localhost:2181
Start Producer
kafka-console-producer.sh --broker-list localhost:9092 --topic stockupdates
# Produce messages for a topic from a file
kafka-console-producer.sh --broker-list localhost:9092 --topic stockupdates < topic-input.txt
/tmp/kafka-logs/
: Default Location of Kafka messages
Start Consumer
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic covid --from-beginning
--from-beginning
: Will broadcast all the message from the producer including the ones before the consumer came online
Apache Kafka CLI commands cheat sheet | by Tim van Baarsen | Medium