flume-----發送 sink 2種本地和hdfs


[root@linux05 conf]# vim hdfssink.conf

//從緩存拿出來   直接到hdfs 中  

******************************************

a1.sources=r1
a1.channels=c1
a1.sinks=k1

a1.sources.r1.type=spooldir
a1.sources.r1.spoolDir=/flume
a1.sources.r1.fileSuffix=.fuck

a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100


a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://linux04:9000/flumelogs
a1.sinks.k1.hdfs.filePrefix = Syslog
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 1
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.fileType=DataStream
a1.sinks.k1.hdfs.writeFormat=Text
a1.sinks.k1.hdfs.rollInterval=0
a1.sinks.k1.hdfs.rollSize=10240
a1.sinks.k1.hdfs.rollCount=0
a1.sinks.k1.hdfs.idleTimeout=60

a1.sinks.k1.channel=c1
a1.sources.r1.channels=c1

***************************************

[root@linux05 conf]# flume-ng agent -c . -f hdfssink.conf -n a1 -Dflume.root.logger=info

 

[root@linux05 flume]# echo "nihao hdfs sink ">>ee.txt

 

 

 //按照時間創建  

hdfs sink 按照日期創建

[root@linux05 conf]# vim hdfssink1.conf 

a1.sources=r1
a1.channels=c1
a1.sinks=k1

a1.sources.r1.type=spooldir
a1.sources.r1.spoolDir=/flume
a1.sources.r1.fileSuffix=.fuck

a1.sources.r1.fileHeader = false
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = timestamp

a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100


a1.sinks.k1.type=hdfs
a1.sinks.k1.hdfs.path=hdfs://linuxo4:9000/flumell
a1.sinks.k1.hdfs.rollInterval=60
a1.sinks.k1.hdfs.rollSize=20000
a1.sinks.k1.hdfs.rollCount=0
a1.sinks.k1.hdfs.idleTimeout=60
a1.sinks.k1.hdfs.fileType=DataStream
a1.sinks.k1.hdfs.round=true
a1.sinks.k1.hdfs.roundValue=10
a1.sinks.k1.hdfs.roundUnit=minute
a1.sinks.k1.hdfs.useLocalTimeStamp=true
a1.sinks.k1.hdfs.filePrefix=%Y-%m-%d

a1.sinks.k1.channel=c1
a1.sources.r1.channels=c1
*********************************************************

[root@linux05 conf]# flume-ng agent -c . -f hdfssink1.conf -n a1 -Dflume.root.logger=info,console

[root@linux05 flume]# echo "ccccccc ">>ee.txt

//結果如圖


 ***************************************************************************************************************************************************************************************************************

2.將數據存儲到本地文件夾

File Roll Sink

vim file.conf

a1.sources=r1
a1.channels=c1
a1.sinks=k1

a1.sources.r1.type=spooldir
a1.sources.r1.spoolDir=/flume
a1.sources.r1.fileSuffix=.fuck

a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100


a1.sinks.k1.type = file_roll   //存到本地
a1.sinks.k1.sink.directory = /flume/logs
a1.sinks.k1.sink.serializer = TEXT

a1.sinks.k1.channel=c1
a1.sources.r1.channels=c1
****************************************************************

[root@linux05 conf]# flume-ng agent -c . -f file.conf -n a1 -Dflume.root.logger=info,console

 

 

[root@linux05 flume]# mkdir logs
[root@linux05 flume]# echo "ccccccc ">>e1.txt
[root@linux05 flume]# echo "ccccccc ">>e2.txt
[root@linux05 flume]# echo "ccccccc ">>e3.txt

 

 //因為按照時間生成的  所以滾動數據  第三個有   前兩個 都是自動生成的

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM