Flume|Flume 数据采集配置

1. Agent 配置

  1. Source 监控文件夹,Channel 保存至内存,Sinks 保存至 HDFS
    # 定义 agent、source、channel、sink 的名称a1.sources = r1 a1.channels = c1 a1.sinks = k1# 定义数据来源(Source) ## 此处定义为 监控 /opt/logs 目录的新增文件 a1.sources.r1.type = spooldir a1.sources.r1.spoolDir = /opt/logs# 定义数据通道(Channel) ## 此处定义为内存保存 a1.channels.c1.type = memory a1.channels.c1.capacity = 10000 a1.channels.c1.transactionCapacity = 100# 定义数据流向何处(Sink) ## 此处定义为保存至 HDFS a1.sinks.k1.type = hdfs# 保存类型 a1.sinks.k1.hdfs.path = hdfs://master:9000/flume/event# 保存路径 a1.sinks.k1.hdfs.filePrefix = events-# 文件前缀 a1.sinks.k1.hdfs.fileType = DataStream# 文件类型(如不配置,默认保存二进制类型)## 不按照文件条数 生成存入 HDFS 的文件 a1.sinks.k1.hdfs.rollCount = 0 ## 按照 128MB 一个文件,存入 HDFS(单位:Byte) a1.sinks.k1.hdfs.rollSize = 134217728 ## 全局定义 60秒生成一个存入 HDFS 的文件 a1.sinks.k1.hdfs.rollInterval = 60# 自定义拦截器 ## a1.sources.r1.interceptors = # 指定 source 和 sink 的 channel a1.sources.r1.channel = c1 a1.sinks.k1.channel = c1

  1. 【Flume|Flume 数据采集配置】Source 使用 NetCat 监听端口
    a1.sources.r1.type = netcat a1.sources.r1.bind = master a1.sources.r1.port = 6666

  1. Source 使用 Avro 反序列化输入
    a1.sources.r1.type = avro a1.sources.r1.bind = slave1 a1.sources.r1.port = 8888

  1. Sink 使用 Avro 序列化输出
    a1.sinks.k1.type = avro a1.sinks.k1.bind = slave1 a1.sinks.k1.port = 8888

2. 启动监听
  1. 首先需要启动 HDFS
  2. 启动 Flume
    # -nAgent名称 # -c配置类型 # -f文件路径(此前编辑的配置文件) # -Dflume.root.logger指定日志级别,并指定打印到控制台bin/flume-ng agent -n a1 -c conf -f conf/conf.properties -Dflume.root.logger=INFO,console

    推荐阅读