Flume1

概念抛出:
操作关系型数据库的数据:RDBMS ==> Sqoop ==> Hadoop
操作非关系型数据库的数据(比如说分散在各个服务器的日志)?==>Hadoop

引出Flume概念:
Flume is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log data. It has a simple and flexible architecture based on streaming data flows. It is robust and fault tolerant with tunable reliability mechanisms and many failover and recovery mechanisms. It uses a simple extensible data model that allows for online analytic application.

collecting        采集     source
aggregating    聚合     channel (找个地方把采集过来的数据暂存处理)
moving           移动     sink

Flume要点:编写配置文件,组合source、channel、sink三者之间的关系
Agent:就是由source、channel、sink组成
编写flume的配置文件其实就是配置agent的构成
总结:Flume就是一个框架:针对日志数据进行采集汇总的一个工具,把日志从A地方搬运到B地方去

Flume部署:
1) 下载(在后方链接找相应版本):http://archive.cloudera.com/cdh5/cdh/5/
2) 解压到~/app
3) 添加到系统环境变量 ~/.bash_profile
export FLUME_HOME=/home/hadoop/app/apache-flume-1.6.0-cdh5.7.0-bin
export PATH=$FLUME_HOME/bin:$PATH
4) $FLUME_HOME/conf/flume-env.sh
    JAVA_HOME

FLUME的简单配置模型:

从指定的网络端口上采集日志到控制台输出
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = 0.0.0.0
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

启动FLUME:
./flume-ng agent \
--name a1 \
--conf $FLUME_HOME/conf \
--conf-file /home/hadoop/script/flume/simple-flume.conf \
-Dflume.root.logger=INFO,console \
-Dflume.monitoring.type=http \
-Dflume.monitoring.port=34343

telnet localhost 44444 客户端连接到FLUME
随便输入一条数据,FLUME端打印:

Event: 一条数据
Event: { headers:{} body: 4C 79 6E 6E 0D                                  Lynn. }
Event:headers + body(字节数组)

Flume支持的source、channel、sink简介:
source
    avro
    exec  : tail -F  xx.log
    Spooling Directory: 
    Taildir
    netcat
sink
    HDFS
    logger
    avro : 配合avro source使用
    kafka
channel
    memory
    file
Agent:组合各种source、channel、sink之间的关系

用法举例:

需求:采集指定文件的内容到HDFS
技术选型:exec - memory - hdfs

./flume-ng agent \
--name a1 \
--conf $FLUME_HOME/conf \
--conf-file /home/hadoop/script/flume/exec-memory-hdfs.conf \
-Dflume.root.logger=INFO,console \
-Dflume.monitoring.type=http \
-Dflume.monitoring.port=34343

    
需求:采集指定文件夹的内容到控制台
选型:spooling - memory - logger
./flume-ng agent \
--name a1 \
--conf $FLUME_HOME/conf \
--conf-file /home/hadoop/script/flume/spooling-memory-logger.conf \
-Dflume.root.logger=INFO,console \
-Dflume.monitoring.type=http \
-Dflume.monitoring.port=34343

taildir
./flume-ng agent \
--name a1 \
--conf $FLUME_HOME/conf \
--conf-file /home/hadoop/script/flume/taildir-memory-logger.conf \
-Dflume.root.logger=INFO,console \
-Dflume.monitoring.type=http \
-Dflume.monitoring.port=34343

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值