Create a topic with topic-level configs
Here's an example of using the kafka-topics.sh
script to create a topic with topic-level configuration in Apache Kafka:
./kafka-topics.sh --create --bootstrap-server <broker-host:port> \
--replication-factor <replication-factor> --partitions <partition-count> \
--topic <topic-name> --config <config-name>=<config-value>
This command creates a new topic with the specified name, replication factor, partition count, and a configuration setting.
For example, to create a topic named "example-topic" with 3 partitions and a replication factor of 2, with a retention period of 7 days:
./kafka-topics
.sh
--create
--bootstrap-server localhost:
9092 \
--replication-factor
2 --partitions
3 --topic example-topic \
--config retention.ms=
604800000
This command creates a topic with the specified properties and a retention period of 7 days, expressed in milliseconds.
Note that the exact set of
available topic-level configurations may vary depending on the version of
Apache Kafka you are using. You can use the --describe
option with the kafka-topics.sh
script to view the
available configurations for a given topic.
Here's an example of using the kafka-topics.sh
script to create a topic with topic-level configuration in Apache Kafka:
./kafka-topics.sh --create --bootstrap-server <broker-host:port> \
--replication-factor <replication-factor> --partitions <partition-count> \
--topic <topic-name> --config <config-name>=<config-value>
This command creates a new topic with the specified name, replication factor, partition count, and a configuration setting.
For example, to create a topic named "example-topic" with 3 partitions and a replication factor of 2, with a retention period of 7 days:
./kafka-topics
.sh
--create
--bootstrap-server localhost:
9092 \
--replication-factor
2 --partitions
3 --topic example-topic \
--config retention.ms=
604800000
This command creates a topic with the specified properties and a retention period of 7 days, expressed in milliseconds.
Note that the exact set of
available topic-level configurations may vary depending on the version of
Apache Kafka you are using. You can use the --describe
option with the kafka-topics.sh
script to view the
available configurations for a given topic.