Updated on 2022-08-12 GMT+08:00

How Do I Create a Topic?

You can create a topic by using one the following three methods:

  • By using the Kafka console

  • By using Kafka Manager

    Log in to Kafka Manager, choose Topic > Create, and set parameters as prompted.

  • By using Kafka CLI

    If your client is v2.2 or later, you can use kafka-topics.sh to create topics and manage topic parameters.

    • If SASL is not enabled for the Kafka instance, run the following command to create a topic:
      ./kafka-topics.sh --create --topic {topic_name} --bootstrap-server {broker_ip}:{port} --partitions {partition_num} --replication-factor {replication_num}
    • If SASL has been enabled for the Kafka instance, perform the following steps to create a topic:
      1. Create the ssl-user-config.properties file in the /config directory of the Kafka client and add the SSL certificate configurations by referring to Accessing a Kafka Instance with SASL.
      2. Run the following command to create a topic:
        ./kafka-topics.sh --create --topic {topic_name} --bootstrap-server {broker_ip}:{port} --partitions {partition_num} --replication-factor {replication_num} --command-config ./config/ssl-user-config.properties