Flume配置Multiplexing Channel Selector
1 官网内容

上面配置的是根据不同的heder当中state值走不同的channels,如果是CZ就走c1 如果是US就走c2 c3 其他默认走c4
2 我的详细配置信息
一个监听http端口 然后 配置两个channel,根据不同的Header中的state值走不同的channel
监听source的配置
#配置文件:
a1.sources= r1
a1.sinks= k1 k2
a1.channels= c1 c2 #Describe/configure the source
a1.sources.r1.type= org.apache.flume.source.http.HTTPSource
a1.sources.r1.port= 50000
a1.sources.r1.host= 127.0.0.1
a1.sources.r1.selector.type= multiplexing
a1.sources.r1.channels= c1 c2 a1.sources.r1.selector.header= state
a1.sources.r1.selector.mapping.CZ= c1
a1.sources.r1.selector.mapping.US= c2
a1.sources.r1.selector.default= c1 #Describe the sink
a1.sinks.k1.type= avro
a1.sinks.k1.channel= c1
a1.sinks.k1.hostname= 127.0.0.1
a1.sinks.k1.port= 50001 a1.sinks.k2.type= avro
a1.sinks.k2.channel= c2
a1.sinks.k2.hostname= 127.0.0.1
a1.sinks.k2.port= 50002
# Usea channel which buffers events in memory
a1.channels.c1.type= memory
a1.channels.c1.capacity= 1000
a1.channels.c1.transactionCapacity= 100 a1.channels.c2.type= memory
a1.channels.c2.capacity= 1000
a1.channels.c2.transactionCapacity= 100
~
~
sink1配置
# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1 # Describe/configure the source
a2.sources.r1.type = avro
a2.sources.r1.channels = c1
a2.sources.r1.bind = 127.0.0.1
a2.sources.r1.port = 50001 # Describe the sink
a2.sinks.k1.type = logger
a2.sinks.k1.channel = c1 # Use a channel which buffers events inmemory
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100
sink2配置
▽
# Name the components on this agent
a3.sources = r1
a3.sinks = k1
a3.channels = c1 # Describe/configure the source
a3.sources.r1.type = avro
a3.sources.r1.channels = c1
a3.sources.r1.bind = 127.0.0.1
a3.sources.r1.port = 50002 # Describe the sink
a3.sinks.k1.type = logger
a3.sinks.k1.channel = c1 # Use a channel which buffers events inmemory
a3.channels.c1.type = memory
a3.channels.c1.capacity = 1000
a3.channels.c1.transactionCapacity = 100
3 在三个终端分别启动
flume-ng agent -cconf -f sink1.conf -n a2 -Dflume.root.logger=INFO,console
flume-ng agent -cconf -f sink2.conf -n a3 -Dflume.root.logger=INFO,console
flume-ng agent -c conf -f multi_source_case.conf -n a1 -Dflume.root.logger=INFO,console
4 再开一个终端发送消息
root@hdp1 /mnt/software/flume-1.6.0/flume-conf]#curl -X POST -d '[{"headers" :{"state" : "CZ"},"body" :"TEST1"}]' http://127.0.0.1:50000
[root@hdp1 /mnt/software/flume-1.6.0/flume-conf]#curl -X POST -d '[{"headers" :{"state" : "US"},"body" :"TEST2"}]' http://127.0.0.1:50000
[root@hdp1 /mnt/software/flume-1.6.0/flume-conf]#curl -X POST -d '[{"headers" :{"state" : "SH"},"body" :"TEST3"}]' http://127.0.0.1:50000
5 观察结果
state为CZ,以及其他值,走了sink1的channel,跟配置的效果一致 19/02/21 05:29:46 INFO ipc.NettyServer: [id: 0xc80ff487, /127.0.0.1:36444 => /127.0.0.1:50001] OPEN
19/02/21 05:29:46 INFO ipc.NettyServer: [id: 0xc80ff487, /127.0.0.1:36444 => /127.0.0.1:50001] BOUND: /127.0.0.1:50001
19/02/21 05:29:46 INFO ipc.NettyServer: [id: 0xc80ff487, /127.0.0.1:36444 => /127.0.0.1:50001] CONNECTED: /127.0.0.1:36444
19/02/21 05:30:38 INFO sink.LoggerSink: Event: { headers:{state=CZ} body: 54 45 53 54 31 TEST1 } 19/02/21 05:33:35 INFO sink.LoggerSink: Event: { headers:{state=SH} body: 54 45 53 54 33 TEST3 } state为US的走了sink2的channel,配置效果一致 UND: /127.0.0.1:50002
19/02/21 05:29:46 INFO ipc.NettyServer: [id: 0xc75a3add, /127.0.0.1:37036 => /127.0.0.1:50002] CONNECTED: /127.0.0.1:37036 19/02/21 05:33:13 INFO sink.LoggerSink: Event: { headers:{state=US} body: 54 45 53 54 32 TEST2 }
Flume配置Multiplexing Channel Selector的更多相关文章
- Flume配置Replicating Channel Selector
1 官网内容 上面的配置是r1获取到的内容会同时复制到c1 c2 c3 三个channel里面 2 详细配置信息 # Name the components on this agent a1.sour ...
- Flume Channel Selector
Flume 基于Channel Selector可以实现扇入.扇出. 同一个数据源分发到不同的目的,如下图. 在source上可以定义channel selector: 1 2 3 4 5 6 7 8 ...
- Hadoop生态圈-Flume的主流Channel源配置
Hadoop生态圈-Flume的主流Channel源配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一. 二. 三.
- flume配置和说明(转)
Flume是什么 收集.聚合事件流数据的分布式框架 通常用于log数据 采用ad-hoc方案,明显优点如下: 可靠的.可伸缩.可管理.可定制.高性能 声明式配置,可以动态更新配置 提供上下文路由功能 ...
- org.apache.flume.conf.ConfigurationException: Channel c1 not in active set.
1 错误详细信息 WARN conf.FlumeConfiguration: Could not configure sink k1 due to: Channel c1 not in active ...
- Flume-Replicating Channel Selector 单数据源多出口
使用 Flume-1 监控文件变动,Flume-1 使用 Replicating Channel Selector 将变动内容传递给 Flume-2,Flume-2 负责存储到 HDFS.同时 Flu ...
- 关于flume配置加载(二)
为什么翻flume的代码,一方面是确实遇到了问题,另一方面是想翻一下flume的源码,看看有什么收获,现在收获还谈不上,因为要继续总结.不够已经够解决问题了,而且确实有好的代码,后续会继续慢慢分享,这 ...
- [从源码学设计] Flume 之 memory channel
[从源码学设计] Flume 之 memory channel 目录 [从源码学设计] Flume 之 memory channel 0x00 摘要 0x01 业务范畴 1.1 用途和特点 1.2 C ...
- 实时事件统计项目:优化flume:用file channel代替mem channel
背景:利用kafka+flume+morphline+solr做实时统计. solr从12月23号开始一直没有数据.查看日志发现,因为有一个同事加了一条格式错误的埋点数据,导致大量error. 据推断 ...
随机推荐
- 纯原生JS大图轮播
CSS部分: CSS: <style type="text/css"> #banner { position: relative; width: 500px; heig ...
- 洛谷P2375 动物园
我要死了.这是我做过的最恶心的题之一. 天下第一的大毒瘤.有gay毒. 我不如熊猫好多年... 题意:给定字符串,求g[i],表示:[0, i]中满足该子串既是前缀又是后缀还不重叠的子串数. 解:题面 ...
- 机器学习三剑客之matplotlib 数据绘图展示
线型图: #导包 import matplotlib.pyplot as plt #导入字体库 from matplotlib.font_manager import FontProperties # ...
- Runtime.getRuntime().exec(...),当参数中有空格时!
原以为不会有什么问题,但在测试时发现,问题大了. 如果想调用f:\mp3\i love you.mp3时, 我原以为正确的写法是: //在文件名前后加个双引号来解决文件名中有空格的情况 String ...
- 斯坦福大学公开课机器学习: advice for applying machine learning | regularization and bais/variance(机器学习中方差和偏差如何相互影响、以及和算法的正则化之间的相互关系)
算法正则化可以有效地防止过拟合, 但正则化跟算法的偏差和方差又有什么关系呢?下面主要讨论一下方差和偏差两者之间是如何相互影响的.以及和算法的正则化之间的相互关系 假如我们要对高阶的多项式进行拟合,为了 ...
- IDEA或Webstorm设置Ctrl+滚轮调整字体大小
按Ctrl+Shift+A,出现搜索框 输入mouse: 点击打开这个设置:勾选 点击ok,之后就可以通过Ctrl+滚轮 调整字体大小了.
- 【NOI2013模拟】坑带的树(仙人球的同构+圆方树乱搞+计数+HASH)
[NOI2013模拟]坑带的树 题意: 求\(n\)个点,\(m\)条边的同构仙人球个数. \(n\le 1000\) 这是一道怎么看怎么不可做的题. 这种题,肯定是圆方树啦~ 好,那么首先转为广义圆 ...
- KMP之计算Next数组
KMP的Next数组:模式串的前缀与后缀的“相交”长度 KMP算法步骤: 1.先算next数组 2.若失配(此时模式串下标为j),利用Next数组求出失配后滑动的新位置 a.Next[j] \geq ...
- 枚举类 enum,结构体类 struct
1.枚举类型的值,直观易于理解,见词知意. 格式: enum 枚举类名:值类型 { 值1, 值2, 值n } 每个值默认(省略“:值类型”)以int型数据存储,从0开始. 使用格式:枚举类名 变量=枚 ...
- 给你的手机加上安全保障,请设置SIM卡PIN码
[手机上了锁,为啥还丢钱?专家支招:设置SIM卡PIN码]智能手机一旦丢失,不仅会带来诸多不便,甚至还会造成个人隐私泄露及财产损失. 然而很多人认为,自己已经设置了手机屏锁.支付密码.指纹锁等防御措施 ...