zoukankan      html  css  js  c++  java
  • Flume(4)实用环境搭建:source(spooldir)+channel(file)+sink(hdfs)方式

    一、概述:

    在实际的生产环境中,一般都会遇到将web服务器比如tomcat、Apache等中产生的日志倒入到HDFS中供分析使用的需求。这里的配置方式就是实现上述需求。

    二、配置文件:

    #agent1 name
    agent1.sources=source1
    agent1.sinks=sink1
    agent1.channels=channel1
    
    
    #Spooling Directory
    #set source1
    agent1.sources.source1.type=spooldir
    agent1.sources.source1.spoolDir=/opt/flumetest/data
    
    agent1.sources.source1.channels=channel1
    agent1.sources.source1.fileHeader = false
    agent1.sources.source1.interceptors = i1
    agent1.sources.source1.interceptors.i1.type = timestamp
    
    #set sink1
    agent1.sinks.sink1.type=hdfs
    agent1.sinks.sink1.hdfs.path=/home/hdfs/flume/logs
    agent1.sinks.sink1.hdfs.fileType=DataStream
    agent1.sinks.sink1.hdfs.writeFormat=TEXT
    agent1.sinks.sink1.hdfs.rollInterval=1
    agent1.sinks.sink1.channel=channel1
    agent1.sinks.sink1.hdfs.filePrefix=%Y-%m-%d
    
    #set channel1
    agent1.channels.channel1.type=file
    agent1.channels.channel1.checkpointDir=/opt/flumetest/cp/point
    agent1.channels.channel1.dataDirs=/opt/flumetest/cp

    三、执行下述命令:

    执行之前先确保上面配置文件中定义的文件夹都已经存在。

    bin/flume-ng agent -n agent1 -c conf -f study/logs2hdfs.conf -Dflume.root.logger=DEBUG,console

    source文件夹中的日志列表如下:

    image

    四、查看hdfs中的数据:

    image

    可以看到里面的数据文件都很小,这跟配置有关系,因为sink的配置里rollInterval配置的时间间隔太小导致的。可以根据需求在进行调整。

  • 相关阅读:
    LINUX开发使用的3个远程工具
    NDK 链接第三方静态库的方法
    GMap.NET 显示GIF图标的定制
    从MySQL获取数据
    web2py远程开发
    升级后,使用dynamic报错
    实用的MVVM:ImageView
    node.js 连接 mysql
    vector常见用法
    XCODE中配置使用boost
  • 原文地址:https://www.cnblogs.com/tq03/p/5154898.html
Copyright © 2011-2022 走看看