简体   繁体   English

log.retention 和 cleanup.policy - Spring Kafka

[英]log.retention and cleanup.policy - Spring Kafka

I have the following configuration in my docker-compose.yml我的docker-compose.yml中有以下配置

kafka:
    image: 'confluentinc/cp-kafka:6.1.0'
    hostname: kafka
    container_name: kafka
    ports:
      - '9092:9092'
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://127.0.0.1:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_LOG_RETENTION_MINUTES: 5
      KAFKA_LOG_CLEANUP_POLICY: compact, delete
    depends_on:
      - zookeeper

I'm using Spring Kafka Binder Streams for creating Topics.我正在使用 Spring Kafka Binder Streams 来创建主题。 Once the application is up, I can see the topics in kafka but I dont see log.retention.minutes or cleanup.policy for the config.应用程序启动后,我可以在 kafka 中看到主题,但看不到配置的log.retention.minutescleanup.policy

it works if I specify the configuration for a specific topic.如果我为特定主题指定配置,它会起作用。 Is it not possible to configure log retention and cleanup at broker level?不能在代理级别配置日志保留和清理吗?

    @Bean
    public NewTopic crateEmployeeTopic() {
        return TopicBuilder
                .name(KafkaConfig.EMP_DATA_TOPIC)
                .partitions(3)
                .config(TopicConfig.RETENTION_MS_CONFIG, "90000")
                .config(TopicConfig.CLEANUP_POLICY_CONFIG, "compact, delete")
                .build();
    }

-- UPDATE -- - 更新 -

I was using Kafdrop UI to check the topic config.我正在使用 Kafdrop UI 来检查主题配置。 It was showing configs when it was defined at topic level, but at the broker level it is not showing any config.它在主题级别定义时显示配置,但在代理级别它不显示任何配置。 I ran the describe command to double check and can now see cleanup.policy , but retention is still missing我运行describe命令进行仔细检查,现在可以看到cleanup.policy ,但仍然缺少retention

$ kafka-topics --bootstrap-server localhost:9092 --describe -- topic  emp_data
Topic: emp_data    PartitionCount: 3      ReplicationFactor: 1    Configs: cleanup.policy=compact,delete
        Topic: emp_data   Partition: 0    Leader: 1       Replicas: 1     Isr: 1

Thank you for your time.感谢您的时间。

this command did the trick.这个命令成功了。

$ kafka-configs --bootstrap-server localhost:9092 --entity-type brokers --entity-name 1 --all --describe | grep retention

You can set broker config for log.retention.minutes as mentioned in here .您可以按照此处所述为log.retention.minutes设置代理配置。 Then all topics that config defaults to it.然后所有配置的主题都默认为它。

cleanup.policy is also same. cleanup.policy也是一样的。 Read here for more information. 阅读此处了解更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 清理策略:压缩/删除和日志保留 - Cleanup Policy:Compact/Delete and log.retention Kafka配置:参数“cleanup.policy”和参数“log.cleanup.policy”有什么区别? - Kafka configuration: what's the difference between parameter "cleanup.policy" and parameter "log.cleanup.policy"? 如果 offsets.retention.minutes=2 和 cleanup.policy=compact,kafka 会删除提交的偏移量还是压缩它 - Will kafka delete the committed offset or compact it if offsets.retention.minutes=2 and cleanup.policy=compact 如何为 Kafka 主题设置 cleanup.policy 'delete' 和 'compact'? - How to set cleanup.policy 'delete' AND 'compact' for a Kafka topic? kafka _schemas 主题删除后,在没有 cleanup.policy 的情况下创建 - kafka _schemas topic when deleted, gets created without cleanup.policy kafka-connect 分布式工作者是否可以使用配置“cleanup.policy=compact,delete”的主题“connect-offset”工作 - could kafka-connect distributed worker work with topic 'connect-offset' with configuration 'cleanup.policy=compact,delete' 为什么主题__consumer_offsets 的cleanup.policy 是COMPACT? - Why does the cleanup.policy of the topic __consumer_offsets is COMPACT? 如何在使用 Spring 创建期间配置 kafka 主题保留策略? - How to configure kafka topic retention policy during creation with Spring? Apache Kafka日志保留配置问题或如何配置Kafka保留策略? - Apache Kafka Log retention configuration issues or How to configure the Kafka retention policy? kafka 上的无限期日志保留 - Indefinite log retention on kafka
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM