IKH

Creating a Topic

Once the servers are up and running, you need to create a topic. For this, leave the terminal windows in which you have started the servers(Zookeeper & Kafka), open a new window and log in to the EC2 instance. In the next video, Vishwa will demonstrate how to create a topic.

In the previous video, you learnt how to create a topic. You also learnt how to view topics that have been created.

The command used to create a topic named ‘test’ with one partition and a replication factor of 1 is as follows:

Example

Python
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

Output

The command used to list the topics is as follows:

Example

Python
bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Output

Note:

Make sure to run the command from the home directory of Apache Kafka.

Report an error