flume

flume:分布式、高可用日志收集工具。


source:数据来源,大致分主动与被动两种。主动是Agent自己去拿的,被动是启动一个服务通过监听一个端口被动接收数据。
channel:可以理解缓冲区。
sink:一般是数据去处的客户端,像发送到kafka。

环境搭建:
1.解压tar -xzvf apache-flume-1.7.0-bin.tar
2.进入安装的conf目录下,拷贝cp flume-conf.properties.template flume.conf
3.配置一个被动的source(netcat),vi flume.conf,配置具体如下:
a.sources = ss
a.channels = c
a.sinks = se


# For each one of the sources, the type is defined
a.sources.ss.type = netcat
a.sources.ss.bind = node01
a.sources.ss.port = 48888




# Each sink's type must be defined
a.sinks.se.type = logger


# Each channel's type is defined.
a.channels.c.type = memory
a.channels.c.capacity = 1000
a.channels.c.transactionCapacity = 100


a.sources.ss.channels = c
a.sinks.se.channel = c
4.启动agent,执行:bin/flume-ng agent --conf ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console -n a
a是flume.conf配置的agent名。
服务启动完毕。
5.用telnet node01 48888,模拟发送数据,看flume是否接受到。

telnet发送数据:


netcat方式flume接收到数据:



主动source配置:
a.sources = ss
a.channels = c
a.sinks = se


# For each one of the sources, the type is defined
a.sources.ss.type = spoolDir        --主动方式
a.sources.ss.spoolDir= /tmp/log --监控该目录下是否有文件产生,有的话flume主动读文件。



# Each sink's type must be defined
a.sinks.se.type = hdfs --发送hdfs上
a.sinks.se.hdfs.path = hdfs://node01:8020/flume/%Y-%m-%d/%H:%M   --产生日志文件的格式
a.sinks.se.hdfs.rollInterval=120 --每120S换个新文件
a.sinks.se.hdfs.rollSize=102400 --每满10M换个新文件
a.sinks.se.hdfs.rollCount=0 --无视次数
a.sinks.se.hdfs.idleTimeout=3 --超时时间3S
a.sinks.se.hdfs.fileType=DataStream --以数据流方式
a.sinks.se.hdfs.useLocalTimeStamp=true --采用本地时间戳
a.sinks.se.hdfs.round=true --采用四舍五入
a.sinks.se.hdfs.roundValue=5 --每五分钟生成目录,该目录下保存该时间段收集到的日志
a.sinks.se.hdfs.roundUnit=minute --以时间为单位



# Each channel's type is defined.
a.channels.c.type = memory
a.channels.c.capacity = 1000
a.channels.c.transactionCapacity = 100


a.sources.ss.channels = c
a.sinks.se.channel = c


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值