flume多路复制案例

多路复制案例

一个source的数据,同时写入到多个channel中,多个channel中的数据是一样的。

Agent1    -à   agent2/agent3

Agent1:

     Source:netcat

     Channel:memory   2

     Sink:avro   2

Agent2:  Agent3:

     Source:avro

     Channel:memory

     Sink:logger

Agent之间的通信   avro

利用一个选择器:

Selecttor.type   决定多路取数据的规则

    

Agent1的配置:

   case_six_agent01.properties

#2个channel和2个sink的配置文件

# Name the components on this agent

a1.sources = s1

a1.sinks = k1 k2

a1.channels = c1 c2

 

# Describe/configure the source

a1.sources.s1.type = netcat

a1.sources.s1.bind = 192.168.191.201

a1.sources.s1.port = 44444

# 指定source进行扇出到多个channnel的规则

a1.sources.s1.selector.type = replicating

a1.sources.s1.channels = c1 c2

 

# Use a channel which buffers events in memory

# 指定channel c1

a1.channels.c1.type = memory

 

# 指定c2的channel

a1.channels.c2.type = memory

 

# Describe the sink

# 指定k1的设置

a1.sinks.k1.type = avro

a1.sinks.k1.channel = c1

a1.sinks.k1.hostname = 192.168.191.202

a1.sinks.k1.port = 44445

 

# 指定k2的

a1.sinks.k2.type = avro

a1.sinks.k2.channel = c2

a1.sinks.k2.hostname = 192.168.191.203

a1.sinks.k2.port = 44445

Agent2的配置:

   case_six_agent02.properties

a1.sources=s1

a1.channels=c1

a1.sinks=k1

 

#设定sources  数据源监听本机的44444端口

a1.sources.s1.channels=c1

a1.sources.s1.type=avro

#指定ip或者主机名

a1.sources.s1.bind=192.168.191.202

#指定需要监控的端口

a1.sources.s1.port=44445

 

#channel

a1.channels.c1.type=memory

 

#sinks  写出数据 logger

a1.sinks.k1.channel=c1

a1.sinks.k1.type=logger

Agent3的配置:

   case_six_agent02.properties

a1.sources=s1

a1.channels=c1

a1.sinks=k1

 

#设定sources  数据源监听本机的44444端口

a1.sources.s1.channels=c1

a1.sources.s1.type=avro

#指定ip或者主机名

a1.sources.s1.bind=192.168.191.203

#指定需要监控的端口

a1.sources.s1.port=44445

 

#channel

a1.channels.c1.type=memory

 

#sinks  写出数据 logger

a1.sinks.k1.channel=c1

a1.sinks.k1.type=logger

上传,发送文件:(也直接发到相应节点上可以)

 

启动:

    先启动agent2 和 agent3:

hadoop02:

    bin/flume-ng agent --conf conf --conf-file /home/hadoop/case_six_agent02.properties --name a1 -Dflume.root.logger=INFO,console

hadoop03:

    bin/flume-ng agent --conf conf --conf-file /home/hadoop/case_six_agent03.properties --name a1 -Dflume.root.logger=INFO,console

再启动agent1:

flume-ng agent --conf conf --conf-file /home/hadoop/case_six_agent01.properties --name a1 -Dflume.root.logger=INFO,console

发送消息

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值