采集需求:比如业务系统使用log4j生成的日志,日志内容不断增加,需要把追加到日志文件中的数据实时采集到hdfs,使用agent串联

根据需求,首先定义以下3大要素

第一台flume agent

l  采集源,即source——监控文件内容更新 :        exec  ‘tail -F file’

l  下沉目标,即sink——数据的发送者,实现序列化  :  avro sink

l  Source和sink之间的传递通道——channel,可用file channel 也可以用 内存channel

第二台flume agent

l  采集源,即source——接受数据。并实现反序列化 : avro source

l  下沉目标,即sink——HDFS文件系统 :  HDFS sink

l  Source和sink之间的传递通道——channel,可用file channel 也可以用 内存channel

配置文件编写:

在mini1的conf下

 vi execsource-avrosink.conf
# 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 /root/logs/test.log # Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = mini2
a1.sinks.k1.port =
a1.sinks.k1.batch-size = # Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

在mini2造数据

while true; do date >>test.log ;sleep .5s; done            

在mini2的conf下

avro-sink.conf
a1.sources = r1
a1.sinks =s1
a1.channels = c1 ##source中的avro组件是一个接收者服务
a1.sources.r1.type = avro
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = a1.sinks.s1.type=hdfs
a1.sinks.s1.hdfs.path=/flumedata
a1.sinks.s1.hdfs.filePrefix = access_log
a1.sinks.s1.hdfs.batchSize=
a1.sinks.s1.hdfs.fileType = DataStream
a1.sinks.s1.hdfs.writeFormat =Text
a1.sinks.s1.hdfs.rollSize =
a1.sinks.s1.hdfs.rollCount =
a1.sinks.s1.hdfs.rollInterval =
a1.sinks.s1.hdfs.round = true
a1.sinks.s1.hdfs.roundValue =
a1.sinks.s1.hdfs.roundUnit = minute a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.sources.r1.channels = c1
a1.sinks.s1.channel = c1

启动

在mini2先启动 bin/flume-ng agent -c conf -f conf/avro-sink.conf -n a1 -Dflume.root.logger=INFO,console
在mini1再启动 bin/flume-ng agent -c conf -f conf/execsource-avrosink.conf -n a1 -Dflume.root.logger=INFO,console

结果

大数据学习——实现多agent的串联,收集数据到HDFS中的更多相关文章

  1. 大数据学习——有两个海量日志文件存储在hdfs

    有两个海量日志文件存储在hdfs上, 其中登陆日志格式:user,ip,time,oper(枚举值:1为上线,2为下线):访问之日格式为:ip,time,url,假设登陆日志中上下线信息完整,切同一上 ...

  2. 大数据学习day35----flume01-------1 agent(关于agent的一些问题),2 event,3 有关agent和event的一些问题,4 transaction(事务控制机制),5 flume安装 6.Flume入门案例

    具体见文档,以下只是简单笔记(内容不全) 1.agent Flume中最核心的角色是agent,flume采集系统就是由一个个agent连接起来所形成的一个或简单或复杂的数据传输通道.对于每一个Age ...

  3. 大数据学习系列之四 ----- Hadoop+Hive环境搭建图文详解(单机)

    引言 在大数据学习系列之一 ----- Hadoop环境搭建(单机) 成功的搭建了Hadoop的环境,在大数据学习系列之二 ----- HBase环境搭建(单机)成功搭建了HBase的环境以及相关使用 ...

  4. 大数据学习系列之五 ----- Hive整合HBase图文详解

    引言 在上一篇 大数据学习系列之四 ----- Hadoop+Hive环境搭建图文详解(单机) 和之前的大数据学习系列之二 ----- HBase环境搭建(单机) 中成功搭建了Hive和HBase的环 ...

  5. 大数据学习系列之六 ----- Hadoop+Spark环境搭建

    引言 在上一篇中 大数据学习系列之五 ----- Hive整合HBase图文详解 : http://www.panchengming.com/2017/12/18/pancm62/ 中使用Hive整合 ...

  6. 大数据学习系列之七 ----- Hadoop+Spark+Zookeeper+HBase+Hive集群搭建 图文详解

    引言 在之前的大数据学习系列中,搭建了Hadoop+Spark+HBase+Hive 环境以及一些测试.其实要说的话,我开始学习大数据的时候,搭建的就是集群,并不是单机模式和伪分布式.至于为什么先写单 ...

  7. 大数据学习系列之九---- Hive整合Spark和HBase以及相关测试

    前言 在之前的大数据学习系列之七 ----- Hadoop+Spark+Zookeeper+HBase+Hive集群搭建 中介绍了集群的环境搭建,但是在使用hive进行数据查询的时候会非常的慢,因为h ...

  8. 大数据学习之Linux进阶02

    大数据学习之Linux进阶 1-> 配置IP 1)修改配置文件 vi /sysconfig/network-scripts/ifcfg-eno16777736 2)注释掉dhcp #BOOTPR ...

  9. 大数据学习之Linux基础01

    大数据学习之Linux基础 01:Linux简介 linux是一种自由和开放源代码的类UNIX操作系统.该操作系统的内核由林纳斯·托瓦兹 在1991年10月5日首次发布.,在加上用户空间的应用程序之后 ...

随机推荐

  1. Datapatch AND What to do if the status of a datapatch action was not SUCCESS due to finding non-ignorable errors

    1. Enterprise Manager: Starting version 12.1 Enterprise Manager now calls datapatch to complete post ...

  2. linux给文件或目录添加apache权限

    系统环境:ubuntu11.10/apache2/php5.3.6 在LAMP环境中,测试一个简单的php文件上传功能时,发现/var/log/apache2/error.log中出现如下php警告: ...

  3. Tomcat+Jenkins+SonarQube+SVN+Maven 集成自动化环境搭建(Windows10环境下)

    说在前面的话: 从接到任务到完成共用了7天的时间.正常人用不到这个时间. 此时的功能表现是: 登录本地JenKins对项目进行构建,能够自动从SVN读取最新代码并按照Maven项目构建,构建完成能够自 ...

  4. hihocoder1067 最近公共祖先·二

    思路: 使用tarjan算法,这是一种离线算法. 实现: #include <bits/stdc++.h> using namespace std; typedef pair<int ...

  5. 在Android上使用酷狗歌词API

    参考自http://blog.csdn.net/u010752082/article/details/50810190 代码先贴出来: public void searchLyric(){ final ...

  6. Tomcat配置Oracle数据源

    开发环境:Eclipse luna.tomcat 7.Oracle 配置Oracle datasource步骤 第一步:打开tomcat目录下的 context.xml 文件,添加 Resource ...

  7. 【HEVC简介】Inter Prediction Tools

    参考文献:见<High Efficiency Video Coding (HEVC)>Inter-Picture Prediction in HEVC章节 <HEVC标准介绍.HEV ...

  8. LibreOJ #101. 最大流

    题目描述 这是一道模板题. 给定 n nn 个点,m mm 条边,给定每条边的容量,求从点 s ss 到点 t tt 的最大流. 输入格式 第一行四个整数 n nn.m mm.s ss.t tt.接下 ...

  9. SQLite运算符

    SQLite运算符 SQLite的运算符是什么? 运算符是一个保留字或一个字符主要用于SQLite语句的WHERE子句来执行操作,如比较和算术运算. 操作符用于指定条件的SQLite语句和作为连词在一 ...

  10. (转)Spring简介

    http://blog.csdn.net/yerenyuan_pku/article/details/52830571 阿昀以一个初学者的身份学习Spring框架,并按照一个小白的思路详细总结学习过程 ...