问题如下:
1、今天忽然出现告警,kafka某节点出现磁盘使用率超过80%告警,回顾最近操作,没有什么大业务变动,此kafka集群已经平稳运行1300多天;
2、检查集群发现,只有此节点有异常,磁盘空间消耗过度;
百度了下,然后如下方案成功解决

查看现有的__consumer_offsets清理策略

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name __consumer_offsets --describe

会有如下输出可以看到 cleanup.policy=compact,则说明cleanup.policy是compact

Configs for topics:__consumer_offsets are segment.bytes=104857600,cleanup.policy=compact,compression.type=producer

__consumer_offsets的确与普通topic在清理策略上不同,也就是参数cleanup.policy上,给__consumer_offsets手动添加了清理策略

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name __consumer_offsets --alter --add-config 'cleanup.policy=delete'

添加完后检查变成了:

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name __consumer_offsets --describe
Configs for topics:__consumer_offsets are segment.bytes=104857600,compression.type=producer,cleanup.policy=delete

执行后5分钟左右磁盘空间就90%下降到了20%使用率。

还看到有文章说 删除特殊清理策略,说是删除特殊清理策略后会使用默认的清理策略, 我用上边的方法处理等了5分钟左右磁盘空间就下来了,;就没有再用下边这个命令了:

bin/kafka-configs.sh --zookeeper  localhost:2181  --entity-type topics --entity-name __consumer_offsets --alter --delete-config cleanup.policy

server.properties配置如下,使用的kafka版本为:kafka_2.11-0.10.0.1

broker.id=2
listeners=PLAINTEXT://:9092
port=9092
host.name=localhost
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/kafka/kafka-logs
num.partitions=2
num.recovery.threads.per.data.dir=1
log.flush.interval.messages=10000
log.flush.interval.ms=1000
log.retention.hours=168
log.retention.bytes=1073741824
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=localhostzk1:2181,localhostzk2:2181,localhostzk3:2181
zookeeper.connection.timeout.ms=6000
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐