Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka topic creation command

Tags:

apache-kafka

I am referring to a book on Kafka. To create a Kafka topic, it states:

Using the command line utility for creating topics on the Kafka server, let’s create a topic named replicated-kafkatopic with two partitions and two replicas:

kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic replicated-kafkatopic

While text states to create 2 partitions and 2 replicas, arguments passed are: 3 for replication-factor and 1 for partitions.

Are arguments correct in context of what text states?

like image 762
Mandroid Avatar asked Feb 17 '26 21:02

Mandroid


1 Answers

No, it must be a typo. If you want to create a topic with two partitions and two replicas, the command should be as follows:

kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic replicated-kafkatopic

The command that you have provided, creates a topic replicated-kafkatopic with 1 partition (--partitions 1) and 3 replicas (--replication-factor 3).

like image 168
Giorgos Myrianthous Avatar answered Feb 21 '26 13:02

Giorgos Myrianthous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!