[英]Kafka configuration: what's the difference between parameter "cleanup.policy" and parameter "log.cleanup.policy"?
[英]Choosing the right cleanup policy in Kafka configuration
我正在使用 kafka_2.10-0.10.0.1。 我創建了 1 個分區的主題。 我知道默認的清理策略是“刪除”。 我想一直保留主題中的所有記錄(不刪除任何記錄)。 什么是正確的方法:使“log.cleaner.enable=false”或“log.cleanup.policy=compact”? 謝謝
主題具有代理范圍的配置,默認情況下適用於沒有配置的任何主題,但主題也可以具有覆蓋或補充代理范圍主題配置的特定於主題的配置。
代理范圍的主題配置在您的service.properties
文件中設置。 如果您使用的是 Java,則使用bin/kafka-topics.sh
腳本或AdminClient
設置特定於主題的配置。
與您相關的代理范圍配置是log.retention.ms
並且等效的特定於主題的配置是retention.ms
。 如果設置log.retention.ms
至-1
,如果沒有這個的所有主題retention.ms
配置將具有無限的保留期。 同樣,如果您為特定主題的retention.ms
時間設置-1
,它將具有無限保留期。
在新主題上設置retention.ms
:
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --create --topic my_topic_name
--partitions 20 --replication-factor 3 --config retention.ms=-1
您還可以修改現有主題以將retention.ms
設置為-1
:
> bin/kafka-configs.sh --zookeeper zk_host:port/chroot --entity-type topics --entity-name my_topic_name --alter --add-config retention.ms=-1
在此處查看特定於主題的配置的完整列表: https : //kafka.apache.org/documentation/#topicconfigs以及有關主題操作的更多信息: https : //kafka.apache.org/documentation/#basic_ops
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.