flume kafka sink

# 指定Agent的组件名称
a1.sources = r1
a1.sinks = k1
a1.channels = c1
 
 
# 指定Flume source(要监听的路径)
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /opt/dir
#每行读取的大小限制
a1.sources.r1.deserializer.maxLineLength = 51200000
 
# 指定Flume sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = topic-test
a1.sinks.k1.brokerList = 192.168.31.244:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 100
#kafka消息生产的大小限制
a1.sinks.k1.kafka.producer.max.request.size=51200000
 
 
# 指定Flume channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
 
 
# 绑定source和sink到channel上
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
Flume中使用Kafka作为Sink的步骤如下: 1. 安装Kafka:首先需要安装Kafka,可以从官网上下载最新版本:https://kafka.apache.org/downloads 2. 配置Kafka:配置Kafka的端口号、主题名称、副本数等参数。在config/server.properties文件中进行配置。 3. 在Flume中添加Kafka Sink:在Flume配置文件中添加一个Kafka Sink,并配置它与Kafka的连接信息和主题等。 4. 启动KafkaFlume:启动KafkaFlume。 以下是一个示例Flume配置文件,使用Kafka作为Sink: ``` # Name the components on this agent agent.sources = source agent.sinks = kafkaSink agent.channels = memoryChannel # Describe/configure the source agent.sources.source.type = netcat agent.sources.source.bind = localhost agent.sources.source.port = 44444 # Describe the sink agent.sinks.kafkaSink.type = org.apache.flume.sink.kafka.KafkaSink agent.sinks.kafkaSink.brokerList = localhost:9092 agent.sinks.kafkaSink.topic = myTopic agent.sinks.kafkaSink.serializer.class = kafka.serializer.StringEncoder # Use a channel which buffers events in memory agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 1000 # Bind the source and sink to the channel agent.sources.source.channels = memoryChannel agent.sinks.kafkaSink.channel = memoryChannel ``` 在这个配置中,使用netcat作为源,监听本地的44444端口。在Kafka Sink中,配置连接信息和主题名称等参数。同时也使用了一个内存中间件,用于缓存事件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值