flume-ng

    Flume-ng是一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力。

    Flume-ng是flume的重构版本,改动比较大。Flume-ng不在依赖于zookeeper。Flume-ng的主要概念有source,channel,sink,agent等。

    event可以理解为flume中的消息格式,数据封装在event中传输。

    source端是用来从外部来获取event,例如web服务器。

    channel是一个数据通道,从source取得的event存储在channel中

    sink端负责从channle中消费event。

    Agent是管理数据从外部源到目的源的一个java进程。

    

1.Flume-ng的安装非常简单,下载安装包后解压即可。  

2.进入在解压后的目录,cd  conf

3.新建文件example.conf

<span style="font-family:SimSun;"># 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 = localhost 
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 
a1.channels.c1.capacity = 1000 
a1.channels.c1.transactionCapacity = 100 
# Bind the source and sink to the channel 
a1.sources.r1.channels = c1 
a1.sinks.k1.channel = c1
</span>

4.启动代理: bin/flume-ng agent --confconf -f conf/example.conf -name a1 -Dflume.root.logger=INFO,console

5.打开另一个命令终端:


6.在agent终端可以看到从console发送的数据



   上面那个例子中,source端消费从本机的44444端口发出的数据,存放在channel中,然后sink端消费数据后显示在console。

   Flume-ng的开发主要是通过配置文件来实现的,在文件中要配置出source,channel,sink等的类型和其他一些参数,还有source和channel,channel和

sink的连接。然后启动agent即可。

   Flume-ng也支持自定义sink和source插件,来满足项目的个性化需求。

   Flume-ng提供了许多内置的source和sink类型,基本上可以满足大部分的开发需求。


示例配置文件:从文件中用tail读出数据写入到hdfs中

<span style="font-family:SimSun;"># Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/lgh/Desktop/test


# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://localhost:8020/flume
a1.sinks.k1.hdfs.fileType = DataStream


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

启动:bin/flume-ng agent –n a1 –c conf –f conf/hdfs.conf -Dflume.root.logger=INFO,console





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值