selector示例

11、复制:同一份数据,发送给两个sink
1个source、2个channel、2个sink
case12_replicate_sink.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1 c2
a1.sinks = k1 k2

#describe/configure the source
a1.sources.r1.type = syslogtcp
a1.sources.r1.host= localhost
a1.sources.r1.port  = 5140
a1.sources.r1.selector.type = replicating
a1.sources.r1.channels = c1 c2

#decribe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname= 192.168.0.106
a1.sinks.k1.port = 4443
a1.sinks.k1.channel = c1

a1.sinks.k2.type = avro
a1.sinks.k2.hostname= 192.168.0.107
a1.sinks.k2.port = 4443
a1.sinks.k2.channel = c1

#use a 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

case12_replicate_s1.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


case12_replicate_s2.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

12、复用:
case13_multi_sink.conf、case13_multi_s1.conf、case13_multi_s2.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1 c2
a1.sinks = k1 k2

#describe/configure the source
a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
a1.sources.r1.host= localhost
a1.sources.r1.port  = 5140
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

#decribe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname= 192.168.0.106
a1.sinks.k1.port = 4443
a1.sinks.k1.channel = c1

a1.sinks.k2.type = avro
a1.sinks.k2.hostname= 192.168.0.107
a1.sinks.k2.port = 4443
a1.sinks.k2.channel = c1

#use a 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

case13_multi_s1.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


case13_multi_s2.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


测试 在source端
curl -X POST -d '[{"headers": {"state":"CZ","datanode":"xx2"},"body":"really_random_body"}]' http://localhost:5140
curl -X POST -d '[{"headers": {"state":"US","datanode":"xx1"},"body":"really_random_body"}]' http://localhost:5140
curl -X POST -d '[{"headers": {"state":"SH","datanode":"xx3"},"body":"really_random_body"}]' http://localhost:5140









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值