0

when we create topic ,where we decide number of partition and replica factor. Do this topic get created in all the brokers? Is it specific to any one broker?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

2 Answers2

0

You are required to pass replication factor and partitions when creating topics.

One which broker(s) each partition and replica are placed, are randomly decided, although you can later use kafka-reassign-partitions to move replicas around to other brokers.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
0

You can crate a topic with this command:

./bin/kafka-topics.sh --create --zookeeper <ZOOKEEPER_URL:PORT> --replication-factor <NO_OF_REPLICATIONS> --partitions <NO_OF_PARTITIONS> --topic <TOPIC_NAME>

After this command metadata about the topic (number of partitions, replicas, ISR list etc.) is stored in Zookeeper. You can get information about topic by this command:

./bin/kafka-topics.sh --zookeeper localhost:2181 --topic TopicName --describe

Replica list of partitions are created according to round-robin algorithm and Controller broker is responsible for noticing new topic creation and triggering partitions assignment.

H.Ç.T
  • 3,335
  • 1
  • 18
  • 37
  • Latest scripts use bootstrap servers rather than Zookeeper – OneCricketeer Jan 18 '20 at 18:16
  • 1
    @cricket_007 Yes. Prior to version 2.2 only zookeeper could be used. But after that both bootstrap-server and zookeeper are valid options. reference: https://cwiki.apache.org/confluence/display/KAFKA/KIP-377%3A+TopicCommand+to+use+AdminClient – H.Ç.T Jan 18 '20 at 18:36