使用flume收集日志,在agent的日志中发现如下错误信息:
Caused by: org.apache.flume.ChannelException: Space for commit to queue couldn't be acquired Sinks are likely not keeping up with sources, or the buffer size is too tight
at org.apache.flume.channel.MemoryChannel$MemoryTransaction.doCommit(MemoryChannel.java:126)
at org.apache.flume.channel.BasicTransactionSemantics.commit(BasicTransactionSemantics.java:151)
at org.apache.flume.channel.ChannelProcessor.processEventBatch(ChannelProcessor.java:192)
... 28 more
解决方法:
1)修改flume-ng agen的堆内存:
vim flume-env.sh
export JAVA_OPTS="-Xms1024m -Xmx1024m"
默认是20m
2)修改channel的配置信息:
agent1.channels.mc1.capacity = 1000
agent1.channels.mc1.keep-alive = 60
解释:
channels | - | |
type | - | 组件类型名称必须是 |
capacity | 100 | 存储在 Channel 当中的最大 events 数 |
transactionCapacity | 100 | 同时刻从Source 获取,或发送到 Sink 的最大 events 数 |
keep-alive | 3 | 添加或删除一个 event 超时的秒数 |
keep-alive"这个参数用来控制channel满时影响source的发送,channel空时影响sink的消费,就是等待时间,默认是3s,超过这个时间就甩异常,一般不需配置,但是有些情况很有用,比如你得场景是每分钟开头集中发一次数据,这时每分钟的开头量可能比较大,后面会越来越小,这时你可以调大这个参数,不至于出现channel满了得情况;