Açıklaması şöyle
In Kafka, the retention policy is a configuration that determines how long Kafka retains messages in a topic before deleting them. The retention policy is important because it affects the amount of disk space that Kafka uses, the performance of the Kafka cluster, and the availability of data for downstream processing. The default retention policy is 7 days, but can optionally be set to forever.
Açıklaması şöyle. Yani varsayılan ayarlarla 1 haftalık sonsuz miktarda veri saklanır. Eğer retention süresini değiştirmek istersek kafka-configs komutu kullanılabilir
Kafka provides settings to control how much data is retained, based on time and size:- The time configuration controlling data retention is log.retention.hours, which defaults to 168 hours (one week).- The size configuration log.retention.bytes controls how large segments can grow before they are eligible for deletion.However, the default setting for log.retention.bytes is -1, which allows the log segment size to be unlimited.
Örnek
Açıklaması şöyle
First you need to find out the offset, you can use the following command to get offset that points to the first record in the topic.It’s important to note that the --time parameter only works for topics with a log compaction policy. If the topic is using a time-based retention policy, the offset will be always -1.
İlk mesajın offset'ini bulmak için şöyle yaparız
./bin/kafka-run-class.sh kafka.tools.GetOffsetShell \ --broker-list localhost:9092 \ --topic my-topic --time -1
Örnek - Her Şeyi Silmek
Şöyle yaparız
kafka-delete-records --bootstrap-server <broker-host:port> \--offset-json-file offsets.json
offsets.json dosyası şöyledir Burada offset olarak -1 verildiği için her şey siliniyor.
{"partitions": [{"topic": "example", "partition": 0, "offset": -1}],"version":1}
No comments:
Post a Comment