
- 外文名
- flume
- 特 点
- 聚合和传输的系统
- 中文名
- 水槽
- 实 质
- 孵化项目
-
Flume
2018-09-11 10:13:17Flume
简介
Flume:Hadoop生态中的日志采集、聚合、传输工具。Flume可以收集各个系统的日志,并提供简单的处理,再写入各类数据接受方。一个Flume实例称为Flume agent,它可分为三个部分:
- Source(数据源):Avro/ Thrift/ Syslog/ Netcat/ HTTP / Spooling Directory/Syslog /Exec /JMS /自定义 /RPC
- Channel:Memory Channel/ File Channel。位于Source和Sink之间的缓冲区,保存通过Source传入到Flume Agent的数据,直到它被Sink移除;
- Sink(数据接收器,可自定义):HDFS/ HBase /RPC /Morphine Solr /ElasticSearch /Null Sink/ Rolling Flie Sink/ Logger /自定义
Flume的基本单元是Agent。一个Flume Agent可以连接一个或多个其他的Agent,也可以从一个或多个Agent接收数据。通过互相连接的多个Flume Agent,一个流作业被建立起来。
日志文件(log):系统或软件对于已完成的行为的记录。依赖日志,我们可以追溯故障、找出BUG、统计数据和分析用户行为。适当的日志可以提供帮助,日志太少和太多都会造成不良影响。而Flume是抽取日志、进行分析的重要工具,特别是几近实时的从前端服务器上将数据放到Hadoop中去。
用一个故事理解: 有一个池子,它一头进水,另一头出水,进水口可以配置各种管子,出水口也可以配置各种管子,可以有多个进水口、多个出水口。水术语称为Event,进水口术语称为Source、出水口术语成为Sink、池子术语成为Channel,Source+Channel+Sink,术语称为Agent。如果有需要,还可以把多个Agent连起来。
其实flume的用法很简单:书写一个配置文件,在配置文件当中描述Source/ Channel/ Sink的属性,然后运行一个agent实例,在运行agent实例的过程中会读取配置文件的内容,这样flume就会采集到数据。
Flume官方文档
Flume Wiki
https://www.cnblogs.com/franson-2016/p/8963834.html
https://blog.csdn.net/weixin_44090237/article/details/89371770
http://www.likuli.com/archives/757/
https://blog.51cto.com/wangyichao/2151587?source=dra
配置
基本命令
# 查看flume版本 flume-ng version # 启动Flume agent;在Flume安装文件夹的根目录下运行 # agent_name,给定的agent名称;flume-conf.properties.template,配置文件 bin/flume-ng agent -n <agent_name> -c conf -f conf/flume-conf.properties.template
demo(source: netcat; channel: memory; sink: logger)
- example.conf的注释以#开头,但只能在每行单独写,不能写在配置代码的后方;
- source: netcat,表示监听某个TCP连接,获取该IP、端口的数据;
- sink: logger,表示以logger形式输出
# http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html#a-simple-example # Name the components on the agent # 该配置文件名称为exanple.conf # 该agent名称为a1,source名称为r1,sink名称为k1,channel名称为c1 a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source # 指定source的类型、source的IP地址、source的监听端口 a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # Describe the sink # 指定sink的类型 a1.sinks.k1.type = logger # Use a channel which buffers eventsin memory # 指定channel的类型,及channel存储数据的容量 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel # 连接r1与c1、连接k1与c1 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1
# 启动flume-ng的命令 # --name:表示该agent的名称 # --conf:表示../flume-ng/conf的文件路径 # --conf-file:表示该agent对应的配置文件的文件路径 # -Dflume.root.logger=DEBUG:表示logger级别在DEBUG及以上即输出log # console:表示在Linux会话的控制台输出log flume-ng agent \ --name a1 \ --conf /opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/etc/flume-ng/conf.empty \ --conf-file /opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/etc/flume-ng/conf.empty/example.conf \ -Dflume.root.logger=DEBUG, console # 开启另外一个Linux会话,并使用telnet建立TCP连接;然后随意输入信息,即可在flume-ng界面收到消息日志 telnet 192.168.103.131 44444
组件
Source
Channel
Sink
Tips:
- Flume和Kafka的异同
- 当数据会被多个消费者使用,则Kafka具有优越性;若日志只被Hadoop使用,则Flume更好;
- Flume内置了很多Source和Sink,若能满足需求,则无需开发任何代码;使用Kafka意味着你准备好了编写你自己的生产者和消费者代码;
- Flume和Kafka可以很好地结合起来使用;
-
flume
2018-09-03 18:28:141:下载flume: wget http://www.apache.org/dyn/closer.lua/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz ... 4: 启动命令:bin/flume-ng agent –conf conf –conf-file conf/flume-conf.prope...flume event简介:
flume –> source : source的种类
最常见的就是taildrr source 和kafka source。flume channel :
flume sink
flume 基本结构:
flume 特性:
1:下载flume: wget http://www.apache.org/dyn/closer.lua/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz
2:解压 :tar -zxf
3: 重命名 : mv
4: 启动命令:bin/flume-ng agent –conf conf –conf-file conf/flume-conf.properties –name agent一:netcat 方式启动,控制台打印
flume-conf-netsrc.properties配置agent.sources = netSrc agent.channels = memoryChannel agent.sources.netSrc.type = netcat agent.sources.netSrc.bind = 0.0.0.0 agent.sources.netSrc.port = 30966 agent.sources.netSrc.channels = memoryChannel
启动命令:
./bin/flume-ng agent --conf conf --conf-file conf/flume-conf-netsrc.properties --name agent -Dflume.root.logger=INFO,console
使用telnet 命令:telnet localhost 30966
返回窗口查看,
-
Apache Flume
2019-12-04 21:49:14Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的软件。 Flume的核心是把数据从数据源(source)收集过来,再将收集到的数据送到指定的目的地(sink)。为了保证输送的过程一定成功,...1丶概述
Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的软件。
Flume的核心是把数据从数据源(source)收集过来,再将收集到的数据送到指定的目的地(sink)。为了保证输送的过程一定成功,在送到目的地(sink)之前,会先缓存数据(channel),待数据真正到达目的地(sink)后,flume在删除自己缓存的数据。
Flume支持定制各类数据发送方,用于收集各类型数据;同时,Flume支持定制各种数据接受方,用于最终存储数据。一般的采集需求,通过对flume的简单配置即可实现。针对特殊场景也具备良好的自定义扩展能力。因此,flume可以适用于大部分的日常数据采集场景。
当前Flume有两个版本。Flume 0.9X版本的统称Flume OG(original generation),Flume1.X版本的统称Flume NG(next generation)。由于Flume NG经过核心组件、核心配置以及代码架构重构,与Flume OG有很大不同,使用时请注意区分。改动的另一原因是将Flume纳入 apache 旗下,Cloudera Flume 改名为 Apache Flume。2丶运行机制
Flume系统中核心的角色是agent,agent本身是一个Java进程,一般运行在日志收集节点。每一个agent相当于一个数据传递员,内部有三个组件:
Source:采集源,用于跟数据源对接,以获取数据;
Sink:下沉地,采集数据的传送目的,用于往下一级agent传递数据或者往
最终存储系统传递数据;
Channel:agent内部的数据传输通道,用于从source将数据传递到sink;
在整个数据的传输的过程中,流动的是event,它是Flume内部数据传输的最基本单元。event将传输的数据进行封装。如果是文本文件,通常是一行记录,event也是事务的基本单位。event从source,流向channel,再到sink,本身为一个字节数组,并可携带headers(头信息)信息。event代表着一个数据的最小完整单元,从外部数据源来,向外部的目的地去。
一个完整的event包括:event headers、event body、event信息,其中event信息就是flume收集到的日记记录。3丶Flume采集系统结构图
3.1简单结构
单个agent采集数据
3.2复杂结构
多级agent之间串联
Flume安装部署
上传安装包到数据源所在节点上
然后解压 tar -zxvf apache-flume-1.8.0-bin.tar.gz
然后进入flume的目录,修改conf下的flume-env.sh,在里面配置JAVA_HOME
根据数据采集需求配置采集方案,描述在配置文件中(文件名可任意自定义)
指定采集方案配置文件,在相应的节点上启动flume agent先用一个最简单的例子来测试一下程序环境是否正常
1、先在flume的conf目录下新建一个文件
vi netcat-logger.conf# 定义这个agent中各组件的名字 a1.sources = r1 a1.sinks = k1 a1.channels = c1 # 描述和配置source组件:r1 a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # 描述和配置sink组件:k1 a1.sinks.k1.type = logger # 描述和配置channel组件,此处使用是内存缓存的方式 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # 描述和配置source channel sink之间的连接关系 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 2、启动agent去采集数据 bin/flume-ng agent -c conf -f conf/netcat-logger.conf -n a1 - Dflume.root.logger=INFO,console -c conf 指定flume自身的配置文件所在目录 -f conf/netcat-logger.con 指定我们所描述的采集方案 -n a1 指定我们这个agent的名字 3、测试 先要往agent采集监听的端口上发送数据,让agent有数据可采。 随便在一个能跟agent节点联网的机器上: telnet anget-hostname port (telnet localhost 44444) 测试会出现 -bash: telnet: command not found 原因 : 没有安装telnet服务 解决方案 yum install telnet-server -y yum install telnet.* -y
-
flume安装配置
2016-11-20 18:43:49flumeflume
参考:
Flume NG 简介及配置实战
Flume介绍与安装1、flume 下载
2、安装
将安装包放到安装路径, 解压:
//解压 tar -zxf apache-flume-1.7.0-bin.tar.gz //移到指定路径 sudo mv apache-flume-1.7.0-bin /usr/local/flume-1.7.0
3、配置参数
3.1、 配置/etc/profile 参数
编辑/etc/profile文件,声明flume的home路径和在path加入bin的路径:
export FLUME_HOME=/usr/local/flume-1.7.0 export FLUME_CONF_DIR=$FLUME_HOME/conf export PATH=$PATH:$FLUME_HOME/bin
编译配置文件/etc/profile,并确认生效
source /etc/profile echo $PATH
3.2、设置flume-env.sh配置文件
在$FLUME_HOME/conf 下复制改名flume-env.sh.template为flume-env.sh,修改conf/ flume-env.sh配置文件:
JAVA_HOME= /app/lib/jdk1.7.0_79 JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
3.3 验证安装
3.3.1、修改flume-conf配置文件 在$FLUME_HOME/conf目录下修改flume-conf.properties.template文件,复制并改名为 flume-conf.properties, 编辑flume-conf.properties:
/usr/local/flume-1.7.0/conf cp flume-conf.properties.template flume-conf2.properties
3.3.2、修改flume-conf.properties:
# The configuration file needs to define the sources, the channels and the sinks. # Sources, channels and sinks are defined per agent, in this case called 'a1' a1.sources = r1 a1.sinks = k1 a1.channels = c1 # For each one of the sources, the type is defined a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 #The channel can be defined as follows. a1.sources.r1.channels = c1 # Each sink's type must be defined a1.sinks.k1.type = logger #Specify the channel the sink should use a1.sinks.k1.channel = c1 # Each channel's type is defined. a1.channels.c1.type = memory # Other config values specific to each type of channel(sink or source) # can be defined as well # In this case, it specifies the capacity of the memory channel a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100
3.3.3、在flume的安装目录/flume-1.7.0下运行
cd /usr/local/flume-1.7.0 ./bin/flume-ng agent --conf ./conf/ --conf-file - ./conf/flume-conf.properties --name a1 -Dflume.root.logger=INFO,console
PS:-Dflume.root.logger=INFO,console 仅为 debug 使用,请勿生产环境生搬硬套,否则大量的日志会返回到终端。。。
-c/–conf 后跟配置目录,-f/–conf-file 后跟具体的配置文件,-n/–name 指定agent的名称
出错:
2016-11-20 08:54:34,702 (main) [ERROR - org.apache.flume.node.Application.main(Application.java:348)] A fatal error occurred while running. Exception follows. org.apache.commons.cli.ParseException: The specified configuration file does not exist: /usr/local/flume-1.7.0/conf/flume-conf2.properties at org.apache.flume.node.Application.main(Application.java:316)
解决:
由于上面的 flume-conf2.properties修改成了 flume-conf.properties, 改一下文件名
3.4、 测试收集日志到HDFS
修改 flume-conf2.properties:
a1.sources = r1 a1.sinks = k1 a1.channels = c1 a1.sources.r1.type = exec a1.sources.r1.channels = c1 //监视的日志文件 a1.sources.r1.command = tail -F /usr/local/hadoop/logs/hadoop-chb-namenode-TEST.log a1.sinks.k1.type = hdfs a1.sinks.k1.channel = c1 //输出到hdfs a1.sinks.k1.hdfs.path = hdfs://192.168.1.124:9000/output/out_flume //输出文件前缀 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.rollSize = 4000000 a1.sinks.k1.hdfs.rollCount = 0 a1.sinks.k1.hdfs.writeFormat = Text a1.sinks.k1.hdfs.fileType = DataStream a1.sinks.k1.hdfs.batchSize = 10 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100
运行flume
cd /usr/local/flume-1.7.0 //运行flume ./bin/flume-ng agent --conf ./conf/ --conf-file ./conf/flume-conf2.properties --name a1 -Dflume.root.logger=INFO,console
查看hdfs中 /output/out_flume中的文件:
hadoop fs -cat /output/out_flume/ hadoop fs -cat /output/out_flume/events-.1479642835192
-
Flume介绍与安装
2018-10-05 11:05:12Flume 1.8.0用户指南 1.介绍 概述 系统要求 2.架构 数据流模型 复杂流动 可靠性 可恢复性 安装 多个Agent 整合 多路复用 配置多Agent流 扇出流 对人工智能感兴趣的同学,可以点击以下链接: 现在人工... -
flume flume基础名字释义
2020-08-27 15:04:56flume基础名字释义Flume EventFlume AgentFlume SourceFlume ChannelFlume SinkFlume ClientApache Flume InterceptorsChannel SelectorsSink Processors Flume Event 在Flume内部传输的数据的基本单位就是Event。 ... -
Flume 概述
2019-05-18 12:15:11Flume 概念 Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统。Flume基于流式架构,灵活简单,主要用于将流数据(日志数据)从各种Web服务器复制到HDFS。 Flume 组成架构 ...