组件介绍:

代理 Flume Agent

  1. Flume内部有一个或者多个Agent
  2. 每一个Agent是一个独立的守护进程(JVM
  3. 从客户端哪儿接收收集,或者从其他的Agent哪儿接收,然后迅速的将获取的数据传到下一个目的节点Agent
  4. Agent主要由sourcechannelsink三个组件组成。

agent source

  1. 一个flume
  2. 负责一个外部源(数据生成器),如一个web服务器传递给他的事件
  3. 该外部源将它的事件以flume可以识别的格式(event)发送到flume
  4. 当一个flume源接收到一个事件时,其将通过一个或多个通道存储该事件

agent channel

  1. 通道: 采用被动存储的形式,即通道会缓存该事件直到该事件被sink组件处理
  2. 所以Channel是一种短暂的存储容器,它将从source处接收到的event格式的数据缓存起来,直到它们被sinks消费掉它在sourcesink间起着一共桥梁的作用,
    channel是一个完整的事务,这一点保证了数据在收发的时候的一致性.并且它可以和任意数量的sourcesink链接
  3. 可以通过参数设置event的最大个数
  4. Flume通常选择FileChannel,而不使用Memory Channel
  5. Memory Channel: 内存存储事务,吞吐率极高,但存在丢数据风险
  6. File Channel: 本地磁盘的事务实现模式,保证数据不会丢失(WAL实现)

监控网络端口使用

  1. netcat
  1. # example.conf: A single-node Flume configuration
  2.  
  3. # Name the components on this agent
  4. a1.sources = r1
  5. a1.sinks = k1
  6. a1.channels = c1
  7.  
  8. # Describe/configure the source
  9. a1.sources.r1.type = netcat
  10. a1.sources.r1.bind = localhost
  11. a1.sources.r1.port = 44444
  12.  
  13. # Describe the sink
  14. a1.sinks.k1.type = logger
  15.  
  16. # Use a channel which buffers events in memory
  17. a1.channels.c1.type = memory
  18. a1.channels.c1.capacity = 1000
  19. a1.channels.c1.transactionCapacity = 100
  20.  
  21. # Bind the source and sink to the channel
  22. a1.sources.r1.channels = c1
  23. a1.sinks.k1.channel = c1

启动命令:flume-ng agent -n a1 -c $FLUME_HOME/conf -f $FLUME_HOME/conf/example.conf -Dflume.root.logger=INFO,console

监控具体文件使用

  1. exec
  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5.  
  6. # Describe/configure the source
  7. a1.sources.r1.type = exec
  8. a1.sources.r1.command = tail -F /home/log/data.log
  9. a1.sources.r1.shell = /bin/bash -c
  10.  
  11. # Describe the sink
  12. a1.sinks.k1.type = logger
  13.  
  14. # Use a channel which buffers events in memory
  15. a1.channels.c1.type = memory
  16.  
  17. # Bind the source and sink to the channel
  18. a1.sources.r1.channels = c1
  19. a1.sinks.k1.channel = c1

启动命令:flume-ng agent -n a1 -c $FLUME_HOME/conf -f $FLUME_HOME/conf/exec-memory-logger.conf -Dflume.root.logger=INFO,console

flume监控日志文件并持久化到hdfs

  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5.  
  6. # Describe/configure the source
  7. a1.sources.r1.type = exec
  8. a1.sources.r1.command = tail -F /home/data/data.log
  9. a1.sources.r1.channels = c1
  10.  
  11. # Describe the sink
  12. a1.sinks.k1.type = hdfs
  13. a1.sinks.k1.channel = c1
  14. a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/
  15. a1.sinks.k1.hdfs.filePrefix = events-
  16. a1.sinks.k1.hdfs.fileType=DataStream
  17. a1.sinks.k1.hdfs.useLocalTimeStamp = true #必须得写 应为14行用到时间数据
  18.  
  19. # Use a channel which buffers events in memory
  20. a1.channels.c1.type = memory
  21.  
  22. # Bind the source and sink to the channel
  23. a1.sources.r1.channels = c1
  24. a1.sinks.k1.channel = c1

别人写的

  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5.  
  6. # Describe/configure the source
  7. ## exec表示flume回去调用给的命令,然后从给的命令的结果中去拿数据
  8. a1.sources.r1.type = exec
  9. ## 使用tail这个命令来读数据
  10. a1.sources.r1.command = tail -F /home/tuzq/software/flumedata/test.log
  11. a1.sources.r1.channels = c1
  12.  
  13. # Describe the sink
  14. ## 表示下沉到hdfs,类型决定了下面的参数
  15. a1.sinks.k1.type = hdfs
  16. ## sinks.k1只能连接一个channel,source可以配置多个
  17. a1.sinks.k1.channel = c1
  18. ## 下面的配置告诉用hdfs去写文件的时候写到什么位置,下面的表示不是写死的,而是可以动态的变化的。表示输出的目录名称是可变的
  19. a1.sinks.k1.hdfs.path = /flume/tailout/%y-%m-%d/%H%M/
  20. ##表示最后的文件的前缀
  21. a1.sinks.k1.hdfs.filePrefix = events-
  22. ## 表示到了需要触发的时间时,是否要更新文件夹,true:表示要
  23. a1.sinks.k1.hdfs.round = true
  24. ## 表示每隔1分钟改变一次
  25. a1.sinks.k1.hdfs.roundValue = 1
  26. ## 切换文件的时候的时间单位是分钟
  27. a1.sinks.k1.hdfs.roundUnit = minute
  28. ## 表示只要过了3秒钟,就切换生成一个新的文件
  29. a1.sinks.k1.hdfs.rollInterval = 3
  30. ## 如果记录的文件大于20字节时切换一次
  31. a1.sinks.k1.hdfs.rollSize = 20
  32. ## 当写了5个事件时触发
  33. a1.sinks.k1.hdfs.rollCount = 5
  34. ## 收到了多少条消息往dfs中追加内容
  35. a1.sinks.k1.hdfs.batchSize = 10
  36. ## 使用本地时间戳
  37. a1.sinks.k1.hdfs.useLocalTimeStamp = true
  38. #生成的文件类型,默认是Sequencefile,可用DataStream:为普通文本
  39. a1.sinks.k1.hdfs.fileType = DataStream
  40.  
  41. # Use a channel which buffers events in memory
  42. ##使用内存的方式
  43. a1.channels.c1.type = memory
  44. a1.channels.c1.capacity = 1000
  45. a1.channels.c1.transactionCapacity = 100
  46.  
  47. # Bind the source and sink to the channel
  48. a1.sources.r1.channels = c1
  49. a1.sinks.k1.channel = c1

flume简介的更多相关文章

  1. Flume简介与使用(二)——Thrift Source采集数据

    Flume简介与使用(二)——Thrift Source采集数据 继上一篇安装Flume后,本篇将介绍如何使用Thrift Source采集数据. Thrift是Google开发的用于跨语言RPC通信 ...

  2. Flume简介与使用(一)——Flume安装与配置

    Flume简介与使用(一)——Flume安装与配置 Flume简介 Flume是一个分布式的.可靠的.实用的服务——从不同的数据源高效的采集.整合.移动海量数据. 分布式:可以多台机器同时运行采集数据 ...

  3. Flume 简介及基本使用

    一.Flume简介 Apache Flume是一个分布式,高可用的数据收集系统.它可以从不同的数据源收集数据,经过聚合后发送到存储系统中,通常用于日志数据的收集.Flume 分为 NG 和 OG (1 ...

  4. 入门大数据---Flume 简介及基本使用

    一.Flume简介 Apache Flume 是一个分布式,高可用的数据收集系统.它可以从不同的数据源收集数据,经过聚合后发送到存储系统中,通常用于日志数据的收集.Flume 分为 NG 和 OG ( ...

  5. Apache Flume 简介

    转自:http://blog.163.com/guaiguai_family/blog/static/20078414520138100562883/ Flume 是 Cloudera 公司开源出来的 ...

  6. Flume简介与使用(三)——Kafka Sink消费数据之Kafka安装

    前面已经介绍了如何利用Thrift Source生产数据,今天介绍如何用Kafka Sink消费数据. 其实之前已经在Flume配置文件里设置了用Kafka Sink消费数据 agent1.sinks ...

  7. Flume简介及安装

    Hadoop业务的大致开发流程以及Flume在业务中的地位: 从Hadoop的业务开发流程图中可以看出,在大数据的业务处理过程中,对于数据的采集是十分重要的一步,也是不可避免的一步,从而引出我们本文的 ...

  8. Flume简介及使用

    一.Flume概述 1)官网地址 http://flume.apache.org/ 2)日志采集工具 Flume是一种分布式,可靠且可用的服务,用于有效地收集,聚合和移动大量日志数据.它具有基于流数据 ...

  9. Apache Flume简介及安装部署

    概述 Flume 是 Cloudera 提供的一个高可用的,高可靠的,分布式的海量日志采集.聚合和传输的软件. Flume 的核心是把数据从数据源(source)收集过来,再将收集到的数据送到指定的目 ...

随机推荐

  1. <Parquet><Physical Properties><Best practice><With impala>

    Parquet Parquet is a columnar storage format for Hadoop. Parquet is designed to make the advantages ...

  2. day 67 django 之ORM 基础安装

    一 ORM的基础部分 1 ORM的概念 对象关系映射(Object Relational Mapping(映射),简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术. 2   ...

  3. winform datatable 或datagridview中添加列

    DataGridViewCheckBoxColumn dg = new DataGridViewCheckBoxColumn(); dg.HeaderText = "选择"; dg ...

  4. 临时调用call()与apply()方法

    当在某个局域范围内要调用构造函数中或者其他局域范围内的方法 此时可以用到临时调用方法call与apply 虽然这两个方法都是起临时调用的功能,但是用法不一样 call(obj,val) obj:对象名 ...

  5. 6--Python入门--Python基本运算符

    算数运算符 运算符 描述 示例 + 相加 1+1→2 - 相减 1-1→0 * 相乘 1*2→2 / 相除 1/2→0.5 % 取余数 3%2→1 ** 幂运算 2**2→4 // 取商 7//2→3 ...

  6. less中使用calc

    css3中可以使用calc()来实现自适应布局 例如:width:“calc(100%  - 25px)” width: calc(expression); ==> expression是一个表 ...

  7. OSPF路由协议(二)

    实验要求:使用OSPF路由协议,使每个路由器都能收集到所有网段 拓扑如下: 配置如下: R1enableconfigure terminalinterface l0ip address 192.168 ...

  8. apache ab 压力测试

    我今天在慕课网中无意之间看到压力测试,可以模拟高并发; 顺便看了一下有没有相关的博客,发现下面的这个很详细; //在apache 安装目录下的bin,运行命令 ab -n1000 -c10 http: ...

  9. PHP设计模式之工厂模式(转)

    概念 工厂模式是我们最常用的实例化对象模式,是用工厂方法代替new操作的一种模式. 使用工厂模式的好处是,如果你想要更改所实例化的类名等,则只需更改该工厂方法内容即可,不需逐一寻找代码中具体实例化的地 ...

  10. drop redo logfile current报错

    目的:在安装完毕11.2.0.4版本Oracle单实例数据库后,对日志进行格式化,删除原日志组current状态,删除报错 #对于理论学习,而带来的理解命令,因此作为记录 #查询日志状态SYS > ...