日志模拟生成脚本
while true;
do
echo 111111111111111111111111_$RANDOM >> access.log;
sleep 0.2;
done
Flume采集配置
#定义这个agent中各个组件的名字,a1是一个分组,在执行的时候可以执行配置文件中指定的组a1.sources = r1a1.channels = c1a1.sinks = k1# source config (描述和配置source组件 r1)a1.sources.r1.channels = c1a1.sources.r1.type = TAILDIRa1.sources.r1.filegroups = g1a1.sources.r1.filegroups.g1 = /var/log/eventlog/access.*a1.sources.r1.header.g1.abc = bbba1.sources.r1.batchSize = 100a1.sources.r1.fileHeader = truea1.sources.r1.fileHeaderKey = fileNamea1.sources.r1.interceptors = i1a1.sources.r1.interceptors.i1.type = timestamp# channel config (描述和配置channel组件 c1)a1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 200# sink config#sink组件和channel组件关联a1.sinks.k1.channel = c1a1.sinks.k1.type = hdfsa1.sinks.k1.hdfs.path = hdfs://doitedu01: 8020 /flume_test/%Y‐%m‐%d/%H‐%M/a1.sinks.k1.hdfs.filePrefix = event_a1.sinks.k1.hdfs.fileSuffix = .loga1.sinks.k1.hdfs.rollInterval = 0a1.sinks.k1.hdfs.rollCount = 0a1.sinks.k1.hdfs.rollSize = 134217728a1.sinks.k1.hdfs.round = truea1.sinks.k1.hdfs.roundValue = 10a1.sinks.k1.hdfs.roundUnit = minutea1.sinks.k1.hdfs.fileType = DataStream
启动命令
bin/flume‐ng agent ‐c conf ‐f agentconf/taildir‐m‐hdfs.properties ‐n a1
添加日志级别调整参数
bin/flume-ng agent -c conf -f /opt/apps/apache-flume-1.9.0-bin/taildir-m-hdfs.conf -n a1 -Dflume.root.logger=INFO,console
添加监控配置
bin/flume-ng agent -c conf -f agentconf/taildir-m-hdfs.properties -n a1 -Dflume.monitoring.type=http -Dflume.monitoring.port=34545
agent 运行一个采集器
-n a1 指定我们这个agent的名字
-c conf 指定flume自身的配置文件所在目录
-f conf/netcat-logger.conf 指定自定义的采集方案
工作环境中的命令为
bin/flume-ng agent -n a1 -c conf -f myconf/taildir-m-hdfs.conf 1>/dev/null 2>&1 &
将一个程序运行在后台,
1的意思是将1里面的标准输出(正确输出)重定向到dev/null文件(抛弃掉,不会存储)里面去,
2的意思是将2里面的错误输出同样重定向到dev/null文件中
&的意思是将程序放到后台执行