- 现象:
主机磁盘告警,磁盘使用率>90%
- 前置条件:
检查磁盘使用率情况,如未出现使用率过高则联系告警平台检查是否存在误告警现象
- 应急流程:
- 登陆告警主机确认磁盘使用率
- 查询各topic数据磁盘占用情况
- 命令调整占用量大topic生命周期
- 操作步骤:
- 查询各topic数据磁盘占用情况:
进入到Kafka部署路径的config目录下,在配置文件server.properties中查询log.dirs配置项,进入log.dirs目录下执行命令
du -sh * | sort -h
- 查询重要程度低的topic的数据过期时间:
挑选磁盘占用较多且重要程度低的topic,查询其数据过期时间,bin目录下执行:
./kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic
retention.ms 即是数据过期毫秒数,不显示该项,则过期时间为默认配置:conf/server.properties 的 log.retention.hours配置
- 修改topic数据保存时长:
减小topic的retention.ms值(可修改为原来的一半)
./kafka-configs.sh --zookeeper localhost:2181 --alter --entity-name mytopic --entity-type topics --add-config retention.ms=21600000
修改后再次查看,确认修改成功。
retention.ms | 含义 | retention.ms | 含义 | retention.ms | 含义 |
---|---|---|---|---|---|
604800000 | 七天 | 64800000 | 18小时 | 28800000 | 8小时 |
259200000 | 三天 | 43200000 | 12小时 | 21600000 | 6小时 |
86400000 | 一天 | 36000000 | 10 小时 |
文章评论