Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
List info for topic1
bin/kafka-list-topic.sh --zookeeper localhost:2121 --topic topic1

List info for all topics
bin/kafka-list-topic.sh --zookeeper localhost:2121 

List info for topics which have under replicated count
bin/kafka-list-topic.sh --zookeeper localhost:2121 --under-replicated-partitions

List info for topics whose leader for a partition is not available
bin/kafka-list-topic.sh --zookeeper localhost:2121 --unavailable-partitions

4. CreateTopicCommand Tool

What does the tool do?

By default, Kafka auto creates topic if "auto.create.topics.enable" is set to true on the server. This creates a topic with a default number of partitions, replication factor and uses Kafka's default scheme to do replica assignment. Sometimes, it may be required that we would like to customize a topic while creating it. This tool helps to create a topic and also specify the number of partitions, replication factor and replica assignment list for the topic.

How to use the tool?

Code Block

./kafka-create-topic.sh 

Option                                  Description                            
------                                  -----------                            
--partition <Integer: # of partitions>    number of partitions in the topic      
                                          (default: 1)               
          
--replica <Integer: replication factor>   replication factor for each partitions 
                                          in the topic (default: 1)        
    
--replica-assignment-list                 for manually assigning replicas to brokers
                                          (default: )      
                                          <broker_id_for_part1_replica1 :                          
                                           broker_id_for_part1_replica2,                                                
                                           broker_id_for_part2_replica1 :                                               
                                           broker_id_for_part2_replica2, ...>                                           

--topic <topic>                         REQUIRED: The topic to be created.     

--zookeeper <urls>                      REQUIRED: The connection string for    
                                          the zookeeper connection in the form 
                                          host:port. Multiple URLS can be      
                                          given to allow fail-over.