Flume下载后,解压,新增一个配置文件,写入配置即可
我将配置文件写在 conf 下,取名为 flume-conf-spooldir.properties
Flume 运行命令:
bin/flume-ng agent --conf conf --conf-file conf/flume-conf-spooldir.properties --name LogAgent -Dflume.root.logger=DEBUG,console
其中,
-Dflume.root.logger=DEBUG,console 纯粹是为了在控制台打印而加的,非必须
之后在/tmp/logs 目录下,放入一个文件,即可看到运行效果
根据此配置文件,会有的效果:
1、hdfs中有 /tmp/logs 放入的文件
2、/tmp/logs 中放入的文件有一个后缀名.complete
注:要保证 HDFS 是启动起来的
配置文件的内容为:
LogAgent.sources = mysource LogAgent.channels = mychannel LogAgent.sinks = mysink LogAgent.sources.mysource.type = spooldir LogAgent.sources.mysource.channels = mychannel LogAgent.sources.mysource.spoolDir =/tmp/logs LogAgent.sinks.mysink.channel = mychannel LogAgent.sinks.mysink.type = hdfs LogAgent.sinks.mysink.hdfs.path = hdfs://node1:9000/data/logs/%Y/%m/%d/%H/ LogAgent.sinks.mysink.hdfs.batchSize = 1000 LogAgent.sinks.mysink.hdfs.rollSize= 0 LogAgent.sinks.mysink.hdfs.rollCount = 10000 LogAgent.sinks.mysink.hdfs.useLocalTimeStamp = true LogAgent.channels.mychannel.type = memory LogAgent.channels.mychannel.capacity = 10000 LogAgent.channels.mychannel.transactionCapacity = 100
时间: 2024-09-30 18:36:02