Flume入门指南

Flume

Apache Flume is a distributed, reliable, and available system for efficiently collecting, aggregating and moving large amounts of log data from many different sources to a centralized data store.

Apache Flume是一个分布式的、可靠的、可用的系统,它可以有效地收集、聚合和移动大量的日志数据,这些数据可以从许多不同的来源转移到一个集中的数据存储中。

架构

配置

  • 配置Source
  • 配置Channel
  • 配置Sink
  • 把三个组件串起来

a1:agent名称

r1:数据源名称

k1:sink名称

c1:channel名称

netcat:

A netcat-like source that listens on a given port and turns each line of text into an event. 

一个类似netcat的源,它监听给定的端口并将每行文本转换成一个事件。

 logger:

Logs event at INFO level. Typically useful for testing/debugging purpose.

记录信息级别的事件。通常用于测试/调试。

memory:

The events are stored in an in-memory queue with configurable max size. It’s ideal for flows that need higher throughput and are prepared to lose the staged data in the event of a agent failures.

事件以可配置的最大大小存储在内存队列中。
对于需要更高吞吐量并且准备在代理失败时丢失分段数据的流来说,这是理想的。 

# example.conf: A single-node Flume configuration

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = hadoop000
a1.sources.r1.port = 44444

# Describe the sink
a1.sinks.k1.type = logger

# Use a channel which buffers events in memory
a1.channels.c1.type = memory

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

一个source可以接多个channel => channels

一个sink只能接一个channel => channel

vi example.conf
将代码粘贴进去
:x
cd $FLUME_HOME/bin
flume-ng agent \
-n a1 \
-c $FLUME_HOME/conf \
-f $FLUME_HOME/conf/example.conf \
-Dflume.root.logger=INFO,console

测试

telnet hadoop000 44444
hello

Flume显示:

2020-03-01 20:52:14,957 (SinkRunner-PollingRunner-DefaultSinkProcessor) 
[INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:94)] 
Event: { headers:{} body: 68 65 6C 6C 6F 0D                               hello. }

Event是Flume数据传输的基本单元,Event = 可选的header + byte array

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值