目录
案例1:监控某个文件夹的变化,将添加的新文件采集存入到hdfs
这篇文章我们来介绍两个flume日志采集的实战案例,案例1:监控某个文件夹的变化,将添加的新文件采集存入到hdfs。案例2:监控某个文件的变化,把变化的内容存储到hdfs上。
flume的安装部署测试在上一篇文章(8)
案例1:监控某个文件夹的变化,将添加的新文件采集存入到hdfs
采集服务器下的某个文件夹(日志文件夹),在该文件夹下产生一个新文件,则该文件中的数据就会被传送到hdfs上的某个文件夹下
采集方案需要确定三大部分
数据源官网
数据下沉:
采集配置文件
最终的配置文件
# example.conf: A single-node Flume configuration
# Name the components on this agent
# 定义代理的名字a1及各个组件sources、sinks和channels
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
# 定义数据源
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /var/log/apache/flumeSpool
a1.sources.r1.fileHeader = true
# Describe the sink
# 定义数据的目的地(下沉)
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/%S
a1.sinks.k1.hdfs.filePrefix = events-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.useLocalTimeStamp = true
# Use a channel which buffers events in memory
# 定义管道
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
#