Config parameters that influence the log retention time.

log.roll.hours  # how long to produce a new log segment.

log.retention.hours   # delete log file how long ago, only when there are more than 1 log segment files, kafka will delete the old one.

log.retention.bytes   # trigger log clean thread when log size up to this limit.

log.segment.bytes  # the max size of log segment, it the max size is reached, new segment will be create, default is 1G.

log delete policy will be triggered once one of the the log.retention.hours and log.retention.bytes is meet or both of them are meet.

only set log.retention.hours to some value could not ensure the message in kafka be deleted after the set value.

if the log clean condition is satisfied, kafka will delete or compact the old one, only if there are more than 1 log segment file.

then, how to pooduce new log segment file?

1.set log.roll.hours to a value less than log.retention.hours, this ensures there will be a new log segment when log.retention.hours is meet.

ps: set log.segment.bytes to a relatively small value, kafka will create new log segment when the segment size is larger than the set value, this not ensure log which is expired could be deleted, because of the case that messages may be not enough to full a log segment file even the log.segment.bytes is set to a relative small value.

if the log.retention.hours needs precision control, the log.roll.hours should be at a fraction of the log.retention.hours, and log.segment.delete.delay.ms should be set to 0(default is 6000 ms), log.retention.check.interval.ms should be set to a small value(default is 300000ms, too small check interval is not recomment, it will cost too many resources to do it.)

Finally, if the log 10 hours ago should be cleaned, what the config should be?

log.roll.hours = 5  # this ensure there will be more than 1 file, when log.retention.hours is meet, and the cleaner therad is triggered. other values such as 1, 2 also works.

log.retention.hours = 10  # this controls the log retention time.

if the log.roll.hours is larger than 10, there will be only 1 file after 10 hours pased, and kafka will not delete the log which exist longer than retention hours.

kafka config的更多相关文章

  1. 在kafka/config/目录下面有3个配置文件参数说明(producer.properties。consumer.properties。server.properties)

    (1).producer.properties:生产端的配置文件 #指定kafka节点列表,用于获取metadata,不必全部指定 #需要kafka的服务器地址,来获取每一个topic的分片数等元数据 ...

  2. Kafka Linux 安装

                            要先设置host, etc/hosts,添加     127.0.0.1 机器名         创建目录             修改日志保存位置   ...

  3. Kafka与Logstash的数据采集对接 —— 看图说话,从运行机制到部署

    基于Logstash跑通Kafka还是需要注意很多东西,最重要的就是理解Kafka的原理. Logstash工作原理 由于Kafka采用解耦的设计思想,并非原始的发布订阅,生产者负责产生消息,直接推送 ...

  4. CentOS 7部署Kafka和Kafka集群

    CentOS 7部署Kafka和Kafka集群 注意事项 需要启动多个shell脚本交互客户端进行验证,运行中的客户端不要停止. 准备工作: 安装java并设置java环境变量,在`/etc/prof ...

  5. ELK+kafka构建日志收集系统

    ELK+kafka构建日志收集系统   原文  http://lx.wxqrcode.com/index.php/post/101.html   背景: 最近线上上了ELK,但是只用了一台Redis在 ...

  6. Kafka+Storm+HDFS整合实践

    在基于Hadoop平台的很多应用场景中,我们需要对数据进行离线和实时分析,离线分析可以很容易地借助于Hive来实现统计分析,但是对于实时的需求Hive就不合适了.实时应用场景可以使用Storm,它是一 ...

  7. kafka迁移数据目录

    问题 先前存储kafka日志的磁盘空间太小,zabbix警报不断,于是加了磁盘,将日志存到新磁盘上. 解决方案 依次在每台机器上操作,保证有机器能响应producer和consumer的操作. 加磁盘 ...

  8. Linux下Kafka单机安装配置方法(图文)

    Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢 介绍 Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了 ...

  9. Kafka的配置文件详细描述

    在kafka/config/目录下面有3个配置文件: producer.properties consumer.properties server.properties (1).producer.pr ...

随机推荐

  1. 第一天课程:第一个python程序print say hello

    print("Hello World") linux下要加可执行权限 chmod 755 hello.py 权限755,7=4+2+1,4是读,2是写,1是执行,第一个7代表用户, ...

  2. Jmeter(二)Jmeter目录介绍

    看过许多有关Jmeter的博客,算得上的收获颇丰:不过最牛逼的博客还是“官方文档”,官方文档是ApacheJmeter自己对自己产品的说明,论起对自己产品的理解程度,那肯定是自己嘛...因此推荐大家从 ...

  3. 邮件过滤-LSTM-Spam Filtering

    Github: https://github.com/cjyanyi/Spam_Filtering_LSTM_Enron 模型结构: CNN-LSTM 开发库: Keras word2vec Enro ...

  4. linux chown命令解除文件夹的root权限限制

    sudo chown -R demouser file 这个命令可以解除linux文件的超级权限限制 摘录: chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID:组可以是组名 ...

  5. Spark Streaming实时数据分析

    [kfk@bigdata-pro01 softwares]$ sudo rpm -ivh nc-.el6.x86_64.rpm Preparing... ####################### ...

  6. ViewPager的addOnPageChangeListener和setOnPageChangeListener的区别,ViewPager改变数据后IndexOutOfBoundsException

    我的ViewPager数据改变后,在切换界面刷新数据时:OnPageChangeListener中的数据IndexOutOfBoundsException,我们来看源码探一下究竟: 代码时这样写的: ...

  7. ubuntu播放音频没声音

    1. 安装pavucontrol sudo apt install pavucontrol 2.配置pavucontrol 在终端执行pavucontrol,弹出设置框进行如下设置:

  8. python学习之----获取标签属性

    到目前为止,我们已经介绍过如何获取和过滤标签,以及获取标签里的内容.但是,在网 络数据采集时你经常不需要查找标签的内容,而是需要查找标签属性.比如标签<a> 指向 的URL 链接包含在hr ...

  9. Windows如何后台运行bat文件(没有命令提示符框)

    怎么让bat文件在后台无声无息无影无形地运行呢? 用start/min命令去运行bat文件,电脑的任务栏下仍然会有相关的图标,以下的办法可以达到目的. 方法一: bat里有隐藏窗口的命令,很简单,只需 ...

  10. TessorFlow学习 之 序言

    2017.10.23日记录: 感觉平时自己学的还不错的,可是面试的时候才发现自己是个渣渣~~,真的感觉学习不能闭门造车! 面试了图像处理算法工程师-->> 1.精通哪门语言?C.C++.P ...