Flume
2021-04-12 09:01:25 0 举报
AI智能生成
Flume笔记
作者其他创作
大纲/内容
概述
Cloudera 提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的软件
运行机制
核心角色是 agent,agent 本身是一个 Java 进程,<br>一般运行在日志收集节点
Source:采集源,用于跟数据源对接,以获取数据<br>
Sink:下沉地,采集数据的传送目的
Channel:agent 内部的数据传输通道,用于从 source 将数据传递到 sink
传输的是数据封装后的event,它是 Flume 内部数据传输的<br>最基本单元。如果是文本文件,通常是一行记录,event 也是事务的基本单位<br>
Flume 采集系统结构图<br>
子主题
Flume案例<br>
采集网络端口数据到内存
# example.conf: A single-node Flume configuration<br><br># Name the components on this agent<br>a1.sources = r1<br>a1.sinks = k1<br>a1.channels = c1<br><br># Describe/configure the source<br>a1.sources.r1.type = netcat<br>a1.sources.r1.bind = localhost<br>a1.sources.r1.port = 44444<br><br># Describe the sink<br>a1.sinks.k1.type = logger<br><br># Use a channel which buffers events in memory<br>a1.channels.c1.type = memory<br>a1.channels.c1.capacity = 1000<br>a1.channels.c1.transactionCapacity = 100<br><br># Bind the source and sink to the channel<br>a1.sources.r1.channels = c1<br>a1.sinks.k1.channel = c1
执行命令:$ bin/flume-ng agent --conf conf --conf-file example.conf --name a1 -Dflume.root.logger=INFO,console<br>
采集目录数据到hdfs
#配置agent组件<br>a1.sources=r1<br>a1.sinks=k1<br>a1.channels=c1<br><br>#配置source<br>a1.sources.r1.type=spooldir<br>a1.sources.r1.spooldir=/var/log/apache/flumeSpool<br>a1.sources.r1.fileHeader=true<br><br><br>#配置sink<br>a1.sinks.k1.type=hdfs<br>a1.sinks.k1.hdfs.fileType=DataStream<br>a1.sinks.k1.hdfs.path=/flume/events/%y-%m-%d/%H%M/%S<br>a1.sinks.k1.hdfs.filePrefix=events-<br>a1.sinks.k1.hdfs.round=true<br>a1.sinks.k1.hdfs.roundValue = 10<br>a1.sinks.k1.hdfs.roundUnit = minute<br><br><br>#配置channel<br>a1.channels.c1.type = memory<br>a1.channels.c1.capacity = 10000<br>a1.channels.c1.transactionCapacity = 10000<br>a1.channels.c1.byteCapacityBufferPercentage = 20<br>a1.channels.c1.byteCapacity = 800000<br><br>#绑定source sink 到channel<br>a1.sources.r1.channels=c1<br>a1.sinks.k1.channel=c1
执行命令:$ bin/flume-ng agent --conf conf --conf-file example.conf --name a1 -Dflume.root.logger=INFO,console
采集文件数据到hdfs
# Name the components on this agent<br>a1.sources = r1<br>a1.sinks = k1<br>a1.channels = c1<br><br># Describe/configure the source<br>a1.sources.r1.type = exec<br>a1.sources.r1.command = tail -F /root/logs/test.log<br>a1.sources.r1.channels = c1<br><br># Describe the sink<br>a1.sinks.k1.type = hdfs<br>a1.sinks.k1.hdfs.path = /flume/tailout/%y-%m-%d/%H%M/<br>a1.sinks.k1.hdfs.filePrefix = eventsa1.sinks.k1.hdfs.round = true<br>a1.sinks.k1.hdfs.roundValue = 10<br>a1.sinks.k1.hdfs.roundUnit = minute<br>a1.sinks.k1.hdfs.rollInterval = 3<br>a1.sinks.k1.hdfs.rollSize = 20<br>a1.sinks.k1.hdfs.rollCount = 5<br>a1.sinks.k1.hdfs.batchSize = 1<br>a1.sinks.k1.hdfs.useLocalTimeStamp = true<br><br>#生成的文件类型,默认是 Sequencefile,可用 DataStream,则为普通文本<br>a1.sinks.k1.hdfs.fileType = DataStream<br># Use a channel which buffers events in memory<br>a1.channels.c1.type = memory<br>a1.channels.c1.capacity = 1000<br>a1.channels.c1.transactionCapacity = 100<br><br># Bind the source and sink to the channel<br>a1.sources.r1.channels = c1<br>a1.sinks.k1.channel = c1<br>
Flume 的 load-balance、failover
<b><font color="#f15a23">load-balance</font><font color="#5c5c5c">(</font><font color="#f15a23">负载均衡</font><font color="#5c5c5c">)</font></b><br>
<b><font color="#f15a23">涉及flume多级启动的时候 建议优先启动远离数据源的</font></b>
<b><font color="#f15a23">failover</font><font color="#5c5c5c">(</font><font color="#f15a23">容错</font><font color="#5c5c5c">)</font></b>
Flume 拦截器实战案例
日志的采集和汇总
Flume 自定义拦截器
Flume 高阶自定义组件
Flume 自定义 Source (扩展)
Flume 自定义 Sink(扩展))
0 条评论
下一页
为你推荐
查看更多