您的位置:首页 > 其它

Flume学习笔记

2015-06-03 09:50 218 查看


Flume学习笔记 


参考资料

中文资料,log资料格式化,sink自定义
http://blog.csdn.net/rjhym

Apache User Guide
https://flume.apache.org/FlumeUserGuide.html

基于cloudera的安装
https://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Installation-Guide/cdh4ig_topic_12.html

load balance
http://blog.csdn.net/morning_pig/article/details/9093149

官网wiki资料,Flume NG,Flume OG介绍,博客,未来研究方向,开发者方向等。
Flume NG (Next Generation) is a huge departure from Flume OG (Original Generation) in its implementation
although many of the original concepts are the same
https://cwiki.apache.org/confluence/display/FLUME/Home

   

架构

    

1)     数据流模式

    一次flume事件定义为一个单元的数据流,该数据流包含一个字节的负荷以及一组可选的字符串属性。一个flume代理是一个JVM进程,用于控制一个组件将外部事件流引导到下一个目的地(hop)。

一个flume源(source)负责一个外部源如一个web服务器传递给它的事件。该外部源将它的事件以Flume可以识别的格式发送到flume。例如,一个Avro的flume源可以从Avro客户端接收Avro事件,或者从其他flume代理出口处(sink)接收来自于其他Avro的事件。当一个flume源接收到一个事件时,其将通过一个或者多个通道存储该事件。通道(channel)采用被动存储的形式,即通道会缓存该事件直到该事件被sink组件处理。存储在本地文件系统的文件通道也是一个常用的例子。Sink会将事件从通道中移除并将事件放置到外部数据仓库,例如通过flume
HDFS sink将数据放置到HDFS中,或者放置到下一个flume的source中,等待下一个flume进行处理。对于缓存在通道中的事件,source和sink采用异步处理的方式。

    

2)高可用的保证

    数据存放在channel中,比如软件坏了?操作系统坏了?硬盘坏了?怎么保证高可用性,怎么恢复数据。

The queue described above is named FlumeEventQueue and the WAL is named Log

开发

开发自定义的SplittingSerializer组件继承于AsyncHbaseEventSerializer ,可以对event进行切分,直接存储到hbase对应的列簇,列中:Streaming
data into Apache HBase using Apache Flume
编写客户端代码,传输数据到avro或者thrift协议中  RPC clients - Avro and Thrift

运行

        

命令行

参考以下的命令工具:
bin/flume-ng agent -n $agent_name -c conf -f conf/flume-conf.properties.template  -Dflume.root.logger=INFO,console 
bin/flume-ng agent --conf conf --conf-file example.conf --name a1 -Dflume.root.logger=INFO,console

官网文档  start a agent

典型配置

#base
agent.sources = tail
agent.channels = memoryChannel
agent.sinks = hdfs-Cluster1-sink
#sources
agent.sources.tail.type = exec
agent.sources.tail.command = tail -f /var/log/flume-ng/flume_test.log
agent.sources.tail.channels = memoryChannel
#agent.sinks.loggerSink.channel = memoryChannel
#agent.sinks.loggerSink.type = logger

#channel
agent.channels.memoryChannel.capacity = 100

#sink
agent.sinks.hdfs-Cluster1-sink.channel = memoryChannel
agent.sinks.hdfs-Cluster1-sink.type = hdfs
agent.sinks.hdfs-Cluster1-sink.hdfs.path = hdfs://10.16.75.22:50070/tmp/test

agent.channels.memoryChannel.type = memory

详细

启动flume的agent的详细过程和步骤  ,参加官网的Starting an agent

注意在flume中:flume1.4+hadoop2.2这两个你是必须换的guava,protobuf   换成hadoop2.2的
 

测试

性能测试

       Flume NG Syslog
Performance Test 2012-04-30 ,基于syslog的性能测试。

Flume configuration
Java version: 1.6.0u26 (Server Hotspot VM)
Java heap size: 2GB
Num. agents: 1
Num. parallel flows: varies (see results)
Source: 
SyslogTcpSource

Channel: 
MemoryChannel

Sink: 
HDFSEventSink
 with 
avro_event
 serialization
and 
snappy
 serializer compression
可以考虑使用serializer compression,提高性能

压力测试

        Flume NG Syslog Stress Test 2012-04-28

所有组件一览表

      Component Summary
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: