1.实现功能:
监控目录,一旦目录内增加数据,即传递到hdfs上。
2.配置文件dir-sink-hdfs.properties
#a1表示代理名称
a1.sources=s1
a1.sinks=k1
a1.channels=c1
#配置source1 监控目录是否有文件数据生成
a1.sources.s1.type=spooldir
a1.sources.s1.spoolDir=/opt/datas/flume/TestDir
a1.sources.s1.channels=c1
a1.sources.s1.fileHeader = false
a1.sources.s1.interceptors = i1
a1.sources.s1.interceptors.i1.type = timestamp
#配置sink1 将检测到的数据sink到hdfs上
a1.sinks.k1.type=hdfs
a1.sinks.k1.hdfs.path=hdfs://bigdata.ibeifeng.com:8020/flume
a1.sinks.k1.hdfs.fileType=DataStream
a1.sinks.k1.hdfs.writeFormat=TEXT
#600s后hdfs上文件才没有tmp,否则有,有tmp则不能看
a1.sinks.k1.hdfs.rollInterval=60
a1.sinks.k1.channel=c1
a1.sinks.k1.hdfs.filePrefix=%Y-%m-%d
#通道是以内存方式存储
#配置channel1
a1.channels.c1.type=memory
a1.channels.c1.capacity=10000
a1.channels.c1.transactionCapacity=100
3.启动flume
bin/flume-ng agent --name a1 --conf conf --conf-file conf/dir-sink-hdfs.properties