第一部分:Flume Interceptors
介绍:resource中的拦截器,与Spring中拦截器类似
功能:通过拦截器对每条数据进行过滤
1.Timestamp Interceptor:时间拦截器
在每一个event的头部添加一个KeyValue
key: timestamp
value:当前封装event的时间
2.Host Interceptor:主机名拦截器
在每一个event的头部添加一个KeyValue
key: host
value:当前封装event所在机器的主机名
3.Static Interceptor:自定义拦截器
a1.sources = r1
a1.channels = c1
a1.sources.r1.channels = c1
a1.sources.r1.type = seq
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = static
a1.sources.r1.interceptors.i1.key = datacenter
a1.sources.r1.interceptors.i1.value = NEW_YORK
4.Regex Filtering Interceptor通过自定义正则表达式,实现对数据过滤
符号该正则,该条数据才会被留下
第二部分:Flume Channel Selectors
selector.type根据该值确定功能
Replicating Channel Selector(默认)
source将每条数据发给每一个channel
source将数据发了多份
1.Multiplexing Channel Selector
source选择性的将数据发送给channel
a1.sources = r1
a1.channels = c1 c2 c3 c4
a1.sources.r1.selector.type = multiplexing
a1.sources.r1.selector.header = state //取出event 头信息中可以是state的值AA
a1.sources.r1.selector.mapping.CZ = c1 //AA==CZ ,发给C1
a1.sources.r1.selector.mapping.US = c2 c3 //AA==US ,发给C2,C3
a1.sources.r1.selector.default = c4
第三部分:Flume Sink Processors
sink的处理器
1.Failover Sink Processor(故障转移)
processor.type= failover
a)启动了多个,但是工作的只有一个,只有active状态进程死掉,其他才可能接替工作。
b)那么多个有多个sink到底谁先工作,根据权重来,谁的权重高,谁先干活。
c)一般故障转移的话,2个sink的类型不一样(HDFS sink ,file sink)
d)比如往HDFS写数据,HDFS宕机了,数据不丢失,往文件里写
2.Load balancing Sink Processor(负载均衡)
processor.type=load_balance
processor.selector = round_robin(轮询)|random(随机)
注:负载均衡与故障转移,只能实现一个,不能同时实现,往往选择负载均衡
387

被折叠的 条评论
为什么被折叠?



