Flume学习笔记之初识(一)
2016-09-27 10:08
363 查看
一、 基本概念
引入:Flume是一个分布式的,可靠的,高可用的海量日志采集、聚合、传输的系统。
数据流模型:source-channel-sink + topology (图1)
事务机制保障了消息传递的可靠性。
有丰富的插件,可以轻松的与其他系统集成。
java实现,适合我们java系程序员研究源代码。
(图1)例子:使用Flume将Nginx Log、Scribe、Kafka数据导入HDFS
基本概念:
Flume基本组件 (图2)
• Event:消息的基本单位,由headers和body组成
• Agent:JVM进程,负责将外部来源产生的消息转发到外部的目
的地
• Source:从外部来源读入event,并写入channel
• Channel:event暂存组件,source写入后,event将会一直
保存,直到被sink成功消费。
• Sink:从channel读入event,并写入目的地
(图2)Flume数据流模型
常见的拓扑结构:
1 聚合模型:
2 分流模型:
二、环境搭建
有两种搭建方式:1. 下载二进制压缩包
• 下载地址:http://flume.apache.org/download.html
2. 编译源码
• gihub地址:git@github.com:apache/flume.git
• maven编译:mvn clean install -DskipTests -Phadoop-2
一个简单的例子(Hello World)
创建conf/example.conf
# name the component on agent a1 ,can name mulity source,sink or channel 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, k1 will print message on console a1.sinks.k1.type = logger # configure the channel, c1 is a memery channel a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity=100 # bind the source and sink to the channel # a sources can have sevel channels a1.sources.r1.channels = c1 # a sink can have only one channel a1.sinks.k1.channel = c1
启动agent:bin/flume-ng agent –conf conf –conf-file conf/helloword.conf –name a1 -Dflume.root.logger=INFO,console
–conf 指定配置文件的根目录,flume可从这个目录读入一些env,log4j等配置。–conf-file指定配置文件,–name 指定agent name,-Dxxx 指定额外配置参数。
3 向44444端口发送Hello World
通过telnet发送Hello World。
Flume接收到HelloWorld
相关文章推荐
- Flume学习笔记之初识(二)
- Flume学习笔记之初识(三)
- [flash and php bible 学习笔记]初识 socket 1
- wpf学习笔记---初识xaml标签语言
- capwap学习笔记——初识capwap(四)
- 初识 sqlite 与 content provider 学习笔记
- Android开发学习笔记(一)——初识Android
- Flume 学习笔记 一 : Flume User Guide
- ASP Forum2.0学习笔记之一---初识default.aspx
- capwap学习笔记——初识capwap(三)
- Linux学习笔记一 ---- Linux基础知识认知以及初识Linux下C编程入门
- 数据挖掘(学习笔记)-初识数据挖掘
- 初识PHP--学习笔记一
- Jquery 学习笔记(一)Jquery初识
- BREW学习笔记 - 初识Brew
- capwap学习笔记——初识capwap(一)
- LISP 学习笔记 (一)-初识LISP,表达式写法
- Extjs学习笔记之一——初识Extjs之MessageBox
- wpf学习笔记---初识xaml标签语言
- android 学习笔记(1) android程序初识