agent.sources = s1
agent.channels = c1
agent.sinks = k1
agent.sources.s1.type=exec
agent.sources.s1.command=tail -F /usr/local/flume/testflume2/hzytest.log
agent.sources.s1.channels=c1
agent.channels.c1.type=memory
agent.channels.c1.capacity=10000
agent.channels.c1.transactionCapacity=100
#设置Kafka接收器
agent.sinks.k1.type= org.apache.flume.sink.kafka.KafkaSink
#设置Kafka的broker地址和端口号
agent.sinks.k1.brokerList=192.168.43.9:9092
#设置Kafka的Topic
agent.sinks.k1.topic=hzytest
#设置序列化方式
agent.sinks.k1.serializer.class=kafka.serializer.StringEncoder
agent.sinks.k1.channel=c1
启动方式
bin/flume-ng agent -c conf -f conf/kafkaflume.conf -n agent -Dflume.root.logger=INFO,console
测试方式
echo '内容' >> hzytest.log kafka就会收到这条消息