0.功能作用:
將時(shí)間戳放到event的header(Map<key,value>)
1.Host.conf
#1.定義agent
a1.sources= r1
a1.sinks = k1
a1.channels = c1
#2.定義source
a1.sources.r1.type = exec
a1.sources.r1.channels = c1
a1.sources.r1.command = tail -F /opt/plus
#攔截器
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = host
#參數(shù)為true時(shí)用IP192.168.1.111,參數(shù)為false時(shí)用主機(jī)名虐先,默認(rèn)為true
a1.sources.r1.interceptors.i1.useIP = false
a1.sources.r1.interceptors.i1.hostHeader = agentHost
#3.定義sinks
a1.sinks.k1.type=hdfs
a1.sinks.k1.hdfs.path = hdfs://hadoop2:9000/flumehost/%{agentHost}
a1.sinks.k1.hdfs.filePrefix = plus_%{agentHost}
#往生成的文件加后綴名.log
a1.sinks.k1.hdfs.fileSuffix = .log
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.rollInterval = 10
a1.sinks.k1.hdfs.useLocalTimeStamp = true
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
2.啟動(dòng)命令:
bin/flume-ng agent -c conf/ -f jobconf/host.conf -n a1 -Dflume.root.logger=INFO,console