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