flume通过kafka channel直接将数据写入kafka时,如果producer一次写入kafka的数据比较大时,会报异常,异常如下:
1 | 15 五月 2017 17:17:09,814 WARN [PollableSourceRunner-TaildirSource-r-op_hiveserver] (org.apache.flume.channel.kafka.KafkaChannel$KafkaTransaction.doCommit:560) - Sending events to Kafka failed |
发送的数据量超过了max.request.size
的阈值(默认是1048576),那就在kafka channel中将此参数调大,a1.channels.c1.kafka.producer.max.request.size = 10485760
接着又出现了如下异常:
1 | 15 五月 2017 17:20:00,799 WARN [PollableSourceRunner-TaildirSource-r-op_hiveserver] (org.apache.flume.channel.kafka.KafkaChannel$KafkaTransaction.doCommit:560) - Sending events to Kafka failed |
异常变了,变成server 不接收,那就是说还得改kafka集群的配置,在server.properties
中添加如下配置:
1 | message.max.bytes=10000120 |
- message.max.bytes是指kafka一次能接收数据的上限,message.max.bytes是针对整个集群进行配置,还可以对某个topic进行配置,参数是
max.message.bytes
,命令为bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic my-topic --config max.message.bytes=10485760
- replica.fetch.max.bytes是从partition中读取数据时的上限,但并不是决对的上限,假如某个非空partition的第一条message的大小超出了此值,依然能够读出。