kafka 日志滚动配置

kafka 定时删除数据

kafka 删除数据其实删除其日志,kafka 的数据其实是kafka 的message 固化到硬盘形成的,她允许配置成一定的策略来删除数据,。

数据删除的方式:首先进入kafka的安装目录,找到其中的config文件夹,然后进入,在里面找到server.properties 文件, 编辑该文件 vi server.properties

操作如下:

cd /usr/oozie

cd config

vi server.properties 

 

在文件中找到 如下文件,

############################# Log Retention Policy #############################

# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.

# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000


从上面的选项中,可以看到这几个可以设置的地方

/* 数据可以保留的最大时长, 达到这个时长的时候, 会删除数据 */

log.retention.hours=168

/* 数据保留的最大值, 达到这个值, 会删除这个数据 */ 

log.segment.bytes=1073741824    

/* 当一个日志块达到指定的值时,会创建新的日块*/

log.segment.bytes=1073741824

/* 检查每个日志块的时间间隔 */

log.retention.check.interval.ms=300000


为了避免在删除时阻塞读操作,采用了copy-on-write形式的实现,删除操作进行时,读取操作的二分查找功能实际是在一个静态的快照副本上进行的

文章也会在公众号更新,欢迎关注!

公众号

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章