大数据课程E5——Flume的Selector

文章作者邮箱:yugongshiye@sina.cn 地址:广东惠州

▲ 本章节目的

⚪ 了解Selector的概念和配置属性;

⚪ 掌握Selector的使用方法;

一、简介

1. 概述

  1. Selector本身是Source的子组件,决定了将数据分发给哪个Channel。

  2. Selector中提供了两种模式:

a. replicating:复制。将数据复制之后发送给每一个节点。

b. multiplexing:路由/多路复用。根据headers中的指定字段决定将数据发送给哪一个Channel。

  1. 如果不指定,那么默认使用的就是复制模式。

2. 配置属性

|---------------------|-------------------------------------------|
| 属性 | 解释 |
| selector.type | 可以是replicating或者multiplexing |
| selector.header | 如果是multiplexing,那么需要指定监听的字段 |
| selector.mapping.* | 如果是multiplexing,那么需要指定监听字段匹配的只 |
| selector.default | 如果是multiplexing,那么在所有值不匹配的情况下数据发送的Channel |

3. 案例

  1. 编写格式文件:

a1.sources = s1

a1.channels = c1 c2

a1.sinks = k1 k2

a1.sources.s1.type = http

a1.sources.s1.port = 8090

指定Selector的类型

a1.sources.s1.selector.type = multiplexing

指定要监听的字段

a1.sources.s1.selector.header = kind

指定匹配的字段值

a1.sources.s1.selector.mapping.music = c1

a1.sources.s1.selector.mapping.video = c2

指定默认值

a1.sources.s1.selector.default = c2

a1.channels.c1.type = memory

a1.channels.c2.type = memory

a1.sinks.k1.type = avro

a1.sinks.k1.hostname = hadoop02

a1.sinks.k1.port = 8090

a1.sinks.k2.type = avro

a1.sinks.k2.hostname = hadoop03

a1.sinks.k2.port = 8090

a1.sources.s1.channels = c1 c2

a1.sinks.k1.channel = c1

a1.sinks.k2.channel = c2

  1. 启动Flume:

../bin/flume-ng agent -n a1 -c ../conf -f multiplexingselector.conf -

Dflume.root.logger=INFO,console

相关推荐
大大大大晴天2 天前
Hudi Metadata Table 与 Hive Sync (HMS)怎么选?
大数据
手可摘星辰7773 天前
一次线上FlinkCDC异常排查复盘
大数据·flink
大大大大晴天3 天前
Hudi技术内幕:Metadata Table原理与实践
大数据
大大大大晴天4 天前
Hudi技术内幕:深入解析Index索引机制
大数据
阿里云大数据AI技术4 天前
Flink Forward Asia 2026 深圳启幕:Agentic Streaming for AI,开启实时智能新范式
大数据·flink
SelectDB4 天前
阶跃星辰基于 SelectDB 构建 PB 级 Agent 可观测平台
大数据·数据库·aigc
大大大大晴天8 天前
Hudi技术内幕:RecordPayload到RecordMerger
大数据
SelectDB8 天前
秒级弹性、最高降本 70%:SelectDB Serverless 如何重塑云数仓资源效率
大数据·后端·云原生
WhoAmI8 天前
MapReduce框架原理解析一:InputFormat
大数据·hadoop
WhoAmI8 天前
MapReduce框架原理解析三:OutputFormat
大数据·hadoop