Adding or Deleting Configurations for a Topic
Symptom
Configure or modify a specific topic when using Kafka.
Parameters that can be modified at the topic level:
cleanup.policycompression.typedelete.retention.msfile.delete.delay.msflush.messagesflush.msindex.interval.bytesmax.message.bytesmin.cleanable.dirty.ratiomin.insync.replicaspreallocateretention.bytesretention.mssegment.bytessegment.index.bytessegment.jitter.mssegment.msunclean.leader.election.enable
Procedure
- Prerequisites
The Kafka client has been installed.
- Procedure
- Log in to the node where the Kafka client is installed as the client installation user.
- Switch to the Kafka client installation directory, for example, /opt/client.
cd /opt/client
- Run the following command to configure environment variables:
source bigdata_env
- Run the following command to perform user authentication (skip this step for a cluster in common mode):
kinit Component service user
- Run the following command to switch to the Kafka client installation directory:
cd Kafka/kafka/bin
- Run the following commands to configure and delete a topic:
kafka-topics.sh --alter --topic <topic_name> --zookeeper <zookeeper_host:port>/kafka --config <name=value>
kafka-topics.sh --alter --topic <topic_name> --zookeeper <zookeeper_host:port>/kafka --delete-config <name>
Example:
kafka-topics.sh --alter --topic test1 --zookeeper 192.168.100.100:2181/kafka --config retention.ms=86400000
kafka-topics.sh --alter --topic test1 --zookeeper 192.168.100.100:2181/kafka --delete-config retention.ms
- Run the following command to query topic information:
kafka-topics.sh --describe -topic <topic_name> --zookeeper <zookeeper_host:port>/kafka
Parent topic: Using Kafka
- Symptom
- Procedure