美文网首页
2018-07-06 flume

2018-07-06 flume

作者: 江江江123 | 来源:发表于2018-07-13 10:24 被阅读0次

    flume:数据采集工具

    核心角色agent

    agent三大组件:

    1.source:采集源
    2.sink:存放地
    3.channel:传输通道

    安装

    1.解压flume
    2.修改con/flume-env.sh
    配置jdk
    3.设置采集配置
    新建log.conf,例子:
    将spooldir下的文件存入hdfs中

    #定义三大组件的名称
    agent1.sources = source1
    agent1.sinks = sink1
    agent1.channels = channel1
    
    # 配置source组件
    agent1.sources.source1.type = spooldir
    agent1.sources.source1.spoolDir = /root/data/
    agent1.sources.source1.fileHeader = false
    
    #配置拦截器,在采集的数据中加入时间
    agent1.sources.source1.interceptors = i1
    agent1.sources.source1.interceptors.i1.type = timestamp
    # 配置sink组件
    agent1.sinks.sink1.type = hdfs
    agent1.sinks.sink1.hdfs.path =/weblog/flume-collection/%y-%m-%d/%H-%M
    agent1.sinks.sink1.hdfs.filePrefix = access_log
    agent1.sinks.sink1.hdfs.maxOpenFiles = 5000
    agent1.sinks.sink1.hdfs.batchSize= 100
    agent1.sinks.sink1.hdfs.fileType = DataStream
    agent1.sinks.sink1.hdfs.writeFormat =Text
    #滚动生成的文件按大小生成
    agent1.sinks.sink1.hdfs.rollSize = 102400
    #滚动生成的文件按行数生成
    agent1.sinks.sink1.hdfs.rollCount = 1000000
    #滚动生成的文件按时间生成
    agent1.sinks.sink1.hdfs.rollInterval = 60
    #开启滚动生成目录
    agent1.sinks.sink1.hdfs.round = true
    #以10为一梯度滚动生成
    agent1.sinks.sink1.hdfs.roundValue = 10
    #单位为分钟
    agent1.sinks.sink1.hdfs.roundUnit = minute
    
    # Use a channel which buffers events in memory
    agent1.channels.channel1.type = memory
    agent1.channels.channel1.capacity = 500000
    agent1.channels.channel1.transactionCapacity = 600
    agent1.channels.channel1.keep-alive = 120
    
    # Bind the source and sink to the channel
    agent1.sources.source1.channels = channel1
    agent1.sinks.sink1.channel = channel1
    

    4.运行

    bin/flume-ng agent -c conf -f conf/log.conf -n a1  -Dflume.root.logger=INFO,console
    

    注:flume同样可以配置高可用,负载均衡

    相关文章

      网友评论

          本文标题:2018-07-06 flume

          本文链接:https://www.haomeiwen.com/subject/hocvuftx.html