Create Kafka Topic

How to create Kafka Topic?

In the previous topic, we have covered about how to setup kafka cluster on windows. Please check the previous topic of Kafka Cluster Setup to understand the setup of kafka cluster so that you can easily create the kafka topic under kafka cluster.

  1. After completed the kafka setup, you need to open command prompt and go to the bin/windows directory of kafka extracted folder in the command prompt.
  2. Write the command below in the command prompt.
    zookeeper-server-start.bat C:\kafka\config\zookeeper.properties
    
    kafka-server-start.bat C:\kafka\config\server.properties
                        
  3. Create Topic
    1. To create a topic, write the command below in the command prompt.
      kafka-topics.bat --create --topic first-topic --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1
    2. To check a topic is created or not, write the command below in the command prompt.
      kafka-topics.bat --list --bootstrap-server localhost:9092
    3. --create --topic : It is the create command to create a topic, it indicates to create a topic.
    4. first-topic : It is the name of topic that you want to create, it indicates to create a topic with this name only.
    5. --bootstrap-server : It is the name of kafka broker.
    6. localhost:9092 : It is the address of kafka broker.
    7. replication-factor 1 : It is the topic's replication factor.
    8. --partitions 1 : It defines about how many partitions for this topic.

    9. kafka Download

In the next topic, you will understand about Create Kafka Producer In Java