设置指定topic下 数据过期时间:

./bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name MARC_INSTANCE_SYNC --alter --add-config retention.ms=1000
Warning: --zookeeper is deprecated and will be removed in a future version of Kafka.
Use --bootstrap-server instead to specify a broker to connect to.
Completed updating config for entity: topic 'MARC_INSTANCE_SYNC'.

确认设置是否成功:
 ./bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-type topics --entity-name MARC_INSTANCE_SYNC
Warning: --zookeeper is deprecated and will be removed in a future version of Kafka.
Use --bootstrap-server instead to specify a broker to connect to.
Configs for topic 'MARC_INSTANCE_SYNC' are retention.ms=1000

删除上面设置:
./bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name MARC_INSTANCE_SYNC --alter --delete-config retention.ms
Warning: --zookeeper is deprecated and will be removed in a future version of Kafka.
Use --bootstrap-server instead to specify a broker to connect to.
Completed updating config for entity: topic 'MARC_INSTANCE_SYNC'.

确认删除是否成功:
 ./bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-type topics --entity-name MARC_INSTANCE_SYNC  Warning: --zookeeper is deprecated and will be removed in a future version of Kafka.
Use --bootstrap-server instead to specify a broker to connect to.
Configs for topic 'MARC_INSTANCE_SYNC' are 
 

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐