Flume 基本使用

配置agent

#init
a1.sources = s1
a1.channels = c1
a1.sinks = k1


# sources
#1、动态监控单个日志文件
#a1.sources.s1.type = exec
#a1.sources.s1.command=tail -F /opt/cdh5.7.6/hive-1.1.0-cdh5.7.6/logs/hive.log
#a1.sources.s1.shell=/bin/sh -c
#2、使用spooldir 读取文件夹下所有文件
#缺点:只能读一层 
#不能动态监控文件变化,读取文件后会修改文件名,然后就会忽略这个文件
#a1.sources.s1.type = spooldir
#a1.sources.s1.spoolDir = /opt/datas/flume/spool
#a1.sources.s1.ignorePattern=(^.+\.tmp$)
#3、TAILDIR方式(推荐)在1.7之上才有,(可以自己集成)
#如果是自己编译的类,这里写类的全路径
a1.sources.s1.type = TAILDIR
#taildir_position.json保存每个文件的监控状态
a1.sources.s1.positionFile =/opt/cdh5.7.6/flume-1.6.0-cdh5.7.6-bin/position/taildir_position.json
a1.sources.s1.filegroups = f1 f2
#读单个文件
a1.sources.s1.filegroups.f1 = /opt/datas/flume/taildir/hd.txt
a1.sources.s1.headers.f1.age = 17
#读文件夹下面所有文件
a1.sources.s1.filegroups.f2 = /opt/datas/flume/taildir/testpk/.*
a1.sources.s1.headers.f2.age = 18
a1.sources.s1.headers.f2.type = aa



#channels
#1、文件
#a1.channels.c1.type = file
#设置检查点,记录相关传输的信息,比如取了多少event
#a1.channels.c1.checkpointDir=/opt/datas/flume/channel/checkpoint
#a1.channels.c1.dataDirs=/opt/datas/flume/channel/data
#2、内存
a1.channels.c1.type = memory
#容量
a1.channels.c1.capacity=1000
#瓶口大小
a1.channels.c1.transactionCapacity=100




#sink
#1、日志收集到hdfs中
a1.sinks.k1.type = hdfs
#存放到hdfs的什么位置,hdfs文件系统路径
a1.sinks.k1.hdfs.path=/flume/taildir
#设置分区 必须给head添加时间戳
#a1.sinks.k1.hdfs.path=/flume/part/yearst=%Y/monthstr=%m/daystr=%d/minutestr=%M
#a1.sinks.k1.hdfs.useLocalTimeStamp=true
#设置文件类型和写的格式
#不会乱码
a1.sinks.k1.hdfs.fileType=DataStream
a1.sinks.k1.hdfs.writeFormat=Text
#设置HDFS文件大小
#解决小文件过多
a1.sinks.k1.hdfs.rollInterval=0
a1.sinks.k1.hdfs.rollSize=10240
a1.sinks.k1.hdfs.rollCount=0
#日志打印
a1.sinks.k1.type = logger

#bind
a1.sources.s1.channels = c1
a1.sinks.k1.channel = c1

运行

//a1为上面agent的名称 case/taildir-file-hdfs.properties为上面配置文件的路径
//-Dflume.root.logger=INFO,console 参数日志信息在控制台打印
bin/flume-ng agent -n a1 -c conf -f case/taildir-file-hdfs.properties -Dflume.root.logger=INFO,console
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值