多个agent串联

采集需求:比如业务系统使用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

配置文件编写:

Flume-agent1:tail-avro-avro-logger.conf

#tail-avro-avro-logger.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

/home/hadoop/bigdatasoftware/datas/access.log

a1.sources.r1.channels = c1

# Describe the sink

##sink端的avro是一个数据发送者

a1.sinks.k1.type = avro

a1.sinks.k1.hostname = hadoop-001

a1.sinks.k1.port = 41414

a1.sinks.k1.batch-size = 10

# 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

Flume-agent2: avro-hdfs.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 = 41414

a1.sinks.s1.type=hdfs

a1.sinks.s1.hdfs.path=hdfs://hadoop-001:9000/logs/flume/

a1.sinks.s1.hdfs.filePrefix = access_log

a1.sinks.s1.hdfs.batchSize= 100

a1.sinks.s1.hdfs.fileType = DataStream

a1.sinks.s1.hdfs.writeFormat =Text

a1.sinks.s1.hdfs.rollSize = 10240

a1.sinks.s1.hdfs.rollCount = 1000

a1.sinks.s1.hdfs.rollInterval = 10

a1.sinks.s1.hdfs.round = true

a1.sinks.s1.hdfs.roundValue = 10

a1.sinks.s1.hdfs.roundUnit = minute

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100

a1.sources.r1.channels = c1

a1.sinks.s1.channel = c1

输入执行flume指令:

第一个终端:


 ./bin/flume-ng agent -c conf -f /home/hadoop/bigdatasoftware/flume-1.5.0/conf/avro-hdfs.conf -n a1 -Dflume.root.logger=INFO,console


第二个终端:


./bin/flume-ng agent -c conf -f /home/hadoop/bigdatasoftware/flume-1.5.0/conf/tail-avro-avro-logger.conf -n a1 -Dflume.root.logger=INFO,console


第三个终端

在/home/hadoop/bigdatasoftware/datas/access.log文件中添加数据

查看hdfs

cat一下

Flume 多个agent串联的更多相关文章

  1. 第1节 flume:9、flume的多个agent串联(级联)

    3.两个agent级联 需求分析: 第一个agent负责收集文件当中的数据,通过网络发送到第二个agent当中去,第二个agent负责接收第一个agent发送的数据,并将数据保存到hdfs上面去 第一 ...

  2. flume中的agent配置和启动

    首先创建一个文件example.conf(touch example.conf) 然后在文件中,进行agent文件的如下的配置(vi  example.conf)   agent文件的配置:(配置ag ...

  3. 大数据学习——实现多agent的串联,收集数据到HDFS中

    采集需求:比如业务系统使用log4j生成的日志,日志内容不断增加,需要把追加到日志文件中的数据实时采集到hdfs,使用agent串联 根据需求,首先定义以下3大要素 第一台flume agent l  ...

  4. 大数据入门第十二天——flume入门

    一.概述 1.什么是flume 官网的介绍:http://flume.apache.org/ Flume is a distributed, reliable, and available servi ...

  5. 日志收集框架flume的安装及简单使用

    flume介绍 Flume是一个分布式.可靠.和高可用的海量日志采集.聚合和传输的系统. Flume可以采集文件,socket数据包等各种形式源数据,又可以将采集到的数据输出到HDFS.hbase.h ...

  6. Flume+Morphlines实现数据的实时ETL

    转载:http://mp.weixin.qq.com/s/xCSdkQo1XMQwU91lch29Uw Apache Flume介绍: Apache Flume是一个Apache的开源项目,是一个分布 ...

  7. Flume日志收集系统架构详解--转

     2017-09-06 朱洁 大数据和云计算技术 任何一个生产系统在运行过程中都会产生大量的日志,日志往往隐藏了很多有价值的信息.在没有分析方法之前,这些日志存储一段时间后就会被清理.随着技术的发展和 ...

  8. Apache Flume的介绍安装及简单案例

    概述 Flume 是 一个高可用的,高可靠的,分布式的海量日志采集.聚合和传输的软件.Flume 的核心是把数据从数据源(source)收集过来,再将收集到的数据送到指定的目的地(sink).为了保证 ...

  9. Flume示例

    建议参考官方文档:http://flume.apache.org/FlumeUserGuide.html 示例一:用tail命令获取数据,下沉到hdfs 类似场景: 创建目录: mkdir /home ...

随机推荐

  1. 1--Selenium环境准备--Eclipse 添加Testng插件

    Eclipse安装TestNG TestNG官网地址:http://testng.org/ 1.离线安装TestNG插件: 受网络等因素影响,在线安装方式速度比较慢,可以通过如下方式离线安装TestN ...

  2. Spring Boot 揭秘与实战(五) 服务器篇 - 内嵌的服务器 Tomcat剖析

    文章目录 1. 内嵌的 Tomcat,一个Jar包运行 2. 如何定制内嵌 Tomcat3. War 包部署的使用细节 2.1. 设置内嵌Tomcat的端口 2.2. 设置内嵌Tomcat的最大线程数 ...

  3. tomcat自动缓存的几种解决方式

    第一种方法:打开一个项目,这里我打开的Mail项目,然后点击Myeclipse菜单栏中的project-选择clean: 选择要clean的项目,确定即可不用进入tomcat服务器直接清理缓存. 上面 ...

  4. Python之路,第七篇:Python入门与基础7

    python3 元组 (tuple) 元组是不可改变的序列, 同list 一样, 元组可以存放任意的值: 表示方法: 用小括号()括起来:  单个元素括起来后加逗号(,)区分单个对象还是元组: 创建空 ...

  5. python中调用多线程加速处理文件

    问题背景是这样的,我有一批需要处理的文件,对于每一个文件,都需要调用同一个函数进行处理,相当耗时 有没有加速的办法呢?当然有啦,比如说你将这些文件分成若干批,每一个批次都调用自己写的python脚本进 ...

  6. mac下python安装MySQLdb模块

    参考:http://blog.csdn.net/yelyyely/article/details/41114449 1.调整到anaconda下的python 2.安装有关程序 brew instal ...

  7. 网络流Dinic算法

    我的模板 例题: https://vjudge.net/problem/HDU-4280 struct Edge { int lst; int from; int to; int cap; int f ...

  8. shell常用函数封装-main.sh

    #!/bin/bash #sunlight sp monitor system #created on 2018/01/07#by chao.dong#used by sp servers consi ...

  9. day python 010 函数(1)

    一 函数 定义 : def () 函数是对功能或者动作的封装 def yue (): # 形参列表 # print("拿出手机") # print("打开陌陌" ...

  10. import sys

    目录 sys模块的常见函数列表 1.sys.argv 2.sys.platform 3.sys.path 4.sys.exit(n) sys模块提供了一系列有关Python运行环境的变量和函数. 回到 ...