实践一:replicating selector

1、目标场景

selector将event复制,分发给所有下游节点

2、Flume Agent配置

Agent配置

# Name the components on this agent
a1.sources = r1
a1.sinks = k1 k2
a1.channels = c1 c2 # http source, with replicating selector
a1.sources.r1.type
= http
a1.sources.r1.port = 6666
a1.sources.r1.bind = master
a1.sources.r1.selector.type =
replicating # Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = slave1 # bind to remote host,RPC
a1.sinks.k1.port = a1.sinks.k2.type = avro
a1.sinks.k2.hostname = slave2 # bind to remote host,PRC
a1.sinks.k2.port = # channels in selector test
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.channels.c2.type = memory
a1.channels.c2.capacity =
a1.channels.c2.transactionCapacity = # bind source ,sink to channels
a1.sources.r1.channels = c1 c2
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2

Collector1配置

#  specify agent,source,sink,channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # 02 avro source,connect to local port 6666
a1.sources.r1.type = avro
a1.sources.r1.bind = slave1
a1.sources.r1.port = # logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

Collector2配置

#  specify agent,source,sink,channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # 02 avro source,connect to local port 6666
a1.sources.r1.type = avro
a1.sources.r1.bind = slave2
a1.sources.r1.port = # logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3、验证Replicating selector

Agent端通过curl -X POST -d 'json数据'  模拟HTTP请求,Agent Souce将其转换为event,并复制两份,分别发给Collector1, Collector2

* 模拟的HTTP请求

* Collector1收到的event

* Collector2收到的event

4、replicating selector的官网配置参考

实践二:multiplexing selector

1、目标场景

2、Flume Agent配置

Agent配置

# Name the components on this agent
a1.sources = r1
a1.sinks = k1 k2
a1.channels = c1 c2 # http source,with multiplexing selector
a1.sources.r1.type = http
a1.sources.r1.bind = master
a1.sources.r1.port = # for header with key country
# send to c1 if country's value is china
# send to c2 if country's value is singapore
a1.sources.r1.selector.type= multiplexing
a1.sources.r1.selector.header= country
a1.sources.r1.selector.mapping.china = c1
a1.sources.r1.selector.mapping.singapore = c2
a1.sources.r1.selector.default=
c1 # Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = slave1 # bind to remote host, RPC
a1.sinks.k1.port = a1.sinks.k2.type = avro
a1.sinks.k2.hostname = slave2 # bind to remote host, RPC
a1.sinks.k2.port = # channels, for selection
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.channels.c2.type = memory
a1.channels.c2.capacity =
a1.channels.c2.transactionCapacity = # bind source,sink to channels
a1.sources.r1.channels= c1 c2
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2

Collector1配置

#  specify agent,source,sink,channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # 02 avro source,connect to local port 6666
a1.sources.r1.type = avro
a1.sources.r1.bind = slave1
a1.sources.r1.port = # logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

Collector2配置

#  specify agent,source,sink,channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # 02 avro source,connect to local port 6666
a1.sources.r1.type = avro
a1.sources.r1.bind = slave2
a1.sources.r1.port = # logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3、验证multiplexing selector

验证思路:

Agent端通过curl -X POST -d 'json数据' 模拟HTTP请求,Agent Souce将其转换为event,并根据header中key为country的不同value值,进行分发
value为china,则分发给C1,最终到达Collecotor1; value为singapore, 则分发给C2,最终到达Collector2; 其他取值,则分发给默认通道C1

1)发送带有country:china的HTTP请求

2)Collecotor1收到并在终端打印出flume event

3)发送带有country:singapore的HTTP请求

4) Collector2收到并在终端打印出flume event

5) 发送带有country:unknown的HTTP请求

6) Collector1因为被配置为默认通道,因此收到该flume event,并打印到终端

4、multiplexing selector官方配置参考

08_Flume_Selector实践的更多相关文章

  1. webp图片实践之路

    最近,我们在项目中实践了webp图片,并且抽离出了工具模块,整合到了项目的基础模板中.传闻IOS10也将要支持webp,那么使用webp带来的性能提升将更加明显.估计在不久的将来,webp会成为标配. ...

  2. Hangfire项目实践分享

    Hangfire项目实践分享 目录 Hangfire项目实践分享 目录 什么是Hangfire Hangfire基础 基于队列的任务处理(Fire-and-forget jobs) 延迟任务执行(De ...

  3. TDD在Unity3D游戏项目开发中的实践

    0x00 前言 关于TDD测试驱动开发的文章已经有很多了,但是在游戏开发尤其是使用Unity3D开发游戏时,却听不到特别多关于TDD的声音.那么本文就来简单聊一聊TDD如何在U3D项目中使用以及如何使 ...

  4. Logstash实践: 分布式系统的日志监控

    文/赵杰 2015.11.04 1. 前言 服务端日志你有多重视? 我们没有日志 有日志,但基本不去控制需要输出的内容 经常微调日志,只输出我们想看和有用的 经常监控日志,一方面帮助日志微调,一方面及 ...

  5. 【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器

    一.反向代理:Web服务器的“经纪人” 1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从 ...

  6. Windows平台分布式架构实践 - 负载均衡

    概述 最近.NET的世界开始闹腾了,微软官方终于加入到了对.NET跨平台的支持,并且在不久的将来,我们在VS里面写的代码可能就可以通过Mono直接在Linux和Mac上运行.那么大家(开发者和企业)为 ...

  7. Mysql事务探索及其在Django中的实践(二)

    继上一篇<Mysql事务探索及其在Django中的实践(一)>交代完问题的背景和Mysql事务基础后,这一篇主要想介绍一下事务在Django中的使用以及实际应用给我们带来的效率提升. 首先 ...

  8. Mysql事务探索及其在Django中的实践(一)

    前言 很早就有想开始写博客的想法,一方面是对自己近期所学知识的一些总结.沉淀,方便以后对过去的知识进行梳理.追溯,一方面也希望能通过博客来认识更多相同技术圈的朋友.所幸近期通过了博客园的申请,那么今天 ...

  9. netty5 HTTP协议栈浅析与实践

      一.说在前面的话 前段时间,工作上需要做一个针对视频质量的统计分析系统,各端(PC端.移动端和 WEB端)将视频质量数据放在一个 HTTP 请求中上报到服务器,服务器对数据进行解析.分拣后从不同的 ...

随机推荐

  1. android 代码edittext删除或者替换光标处的字串

    https://stackoverflow.com/questions/3609174/android-insert-text-into-edittext-at-current-position Cp ...

  2. vue学习之webpack

    本质上,Webpack是一个现代 JavaScript应用程序的静态模块打包器(module bundler).当 Webpack处理应用程序时,它会递归地构建一个依赖关系图(dependency g ...

  3. 多线程下载文件,ftp文件服务器

    1: 多线程下载文件 package com.li.multiplyThread; import org.apache.commons.lang3.exception.ExceptionUtils; ...

  4. PAT 1040 Longest Symmetric String[dp][难]

    1040 Longest Symmetric String (25)(25 分) Given a string, you are supposed to output the length of th ...

  5. 分布式文件系统ceph快速部署

    架构图 配置ceph-deploy节点 管理节点配置ceph yum源 vim /etc/yum.repos.d/ceph.repo [ceph-noarch] name=Ceph noarch pa ...

  6. Problem B. Full Binary Tree

    题目 链接:http://code.google.com/codejam/contest/2984486/dashboard#s=p1 googlde code jam 2014 Round1A 解题 ...

  7. [转]Visual C++ RunTime的特征——非烫即屯

    Visual C++ RunTime的特征——非烫即屯 大一刚学C语言,第二次上机课,当我发现我照着书抄写的程序在运行之外的黑框里面跳出一排“烫烫烫烫烫”,当时就震惊了.你们能想象一个来自小城, 在大 ...

  8. kail linux nmap命令

    可用于: 检测活在网络上的主机(主机发现)检测主机上开放的端口(端口发现或枚举)检测到相应的端口(服务发现)的软件和版本检测操作系统,硬件地址,以及软件版本检测脆弱性的漏洞(Nmap的脚本) ---- ...

  9. MySQL从删库到跑路_高级(四)——存储过程

    作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.存储过程简介 1.存储过程简介 存储过程是一组具有特定功能的SQl语句集组成的可编程的函数,经编译创建并保存在数 ...

  10. python sys.stdin、sys.stdout和sys.stderr

    学习并转载自  https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使用raw_input( ...