flume-ng负载均衡load-balance、failover集群搭建

集群采用3台机器:

[html]  view plain copy
  1. host1 load-balance设置  
  2. host2 机器1  
  3. host3 机器2  


其中,host1 机器配置:

[html]  view plain copy
  1. #Define a memory channel called c1 on a1  
  2. a1.channels = c1  
  3. a1.sources = r1  
  4. a1.sinks = k1 k2  
  5. a1.sinkgroups = g1  
  6. a1.sinkgroups.g1.sinks = k1 k2  
  7. a1.sinkgroups.g1.processor.type = load_balance  
  8. a1.sinkgroups.g1.processor.selector = round_robin  
  9. a1.sinkgroups.g1.processor.backoff = true  
  10.   
  11. a1.channels.c1.type = file   
  12. a1.channels.c1.checkpointDir = /tmp/flume/loadcheckpoint  
  13. a1.channels.c1.dataDirs = /tmp/flume/loaddata  
  14.   
  15. a1.sources.r1.channels = c1  
  16. a1.sources.r1.type = avro  
  17. a1.sources.r1.bind = 0.0.0.0  
  18. a1.sources.r1.port = 41415  
  19.   
  20. a1.sinks.k1.channel = c1  
  21. a1.sinks.k1.type = avro  
  22. a1.sinks.k1.hostname = host2  
  23. a1.sinks.k1.port = 41414  
  24. a1.sinks.k2.channel = c1  
  25. a1.sinks.k2.type = AVRO  
  26. a1.sinks.k2.hostname = host3  
  27. a1.sinks.k2.port = 41414  


host2 机器配置:

[html]  view plain copy
  1. a2.channels = c1  
  2. a2.sources = r1  
  3. a2.sinks = k1  
  4.   
  5. a2.channels.c1.type = FILE  
  6. a1.channels.c1.checkpointDir = /tmp/flume/checkpoint  
  7. a1.channels.c1.dataDirs = /tmp/flume/data  
  8.   
  9. a2.sources.r1.channels = c1  
  10. a2.sources.r1.type = AVRO  
  11. a2.sources.r1.bind = 0.0.0.0  
  12. a2.sources.r1.port = 41414  
  13.   
  14. a2.sinks.k1.channel = c1  
  15. a2.sinks.k1.type = file_roll  
  16. a2.sinks.k1.sink.directory = /tmp/load/  
  17. a2.sinks.k1.sink.rollInterval = 0  

 

host3 机器配置:

[html]  view plain copy
  1. a2.channels = c1  
  2. a2.sources = r1  
  3. a2.sinks = k1  
  4.   
  5. a2.channels.c1.type = FILE  
  6. a1.channels.c1.checkpointDir = /tmp/flume/checkpoint  
  7. a1.channels.c1.dataDirs = /tmp/flume/data  
  8.   
  9. a2.sources.r1.channels = c1  
  10. a2.sources.r1.type = AVRO  
  11. a2.sources.r1.bind = 0.0.0.0  
  12. a2.sources.r1.port = 41414  
  13.   
  14. a2.sinks.k1.channel = c1  
  15. a2.sinks.k1.type = file_roll  
  16. a2.sinks.k1.sink.directory = /tmp/load/  
  17. a2.sinks.k1.sink.rollInterval = 0  


客户端机器暂时使用flume-ng的agent发送,配置如下:

[html]  view plain copy
  1. # Define a memory channel called c1 on a1  
  2. a1.channels.c1.type = file   
  3. a1.channels.c1.checkpointDir = /tmp/flume/checkpoint  
  4. a1.channels.c1.dataDirs = /tmp/flume/data  
  5.   
  6.   
  7. a1.sources.r1.channels = c1  
  8. a1.sources.r1.type = exec  
  9. a1.sources.r1.command = cat /tmp/linux.log  
  10.   
  11. a1.sinks.k1.type = avro   
  12. a1.sinks.k1.channel = c1  
  13. a1.sinks.k1.hostname = host1  
  14. a1.sinks.k1.port = 41415  
  15.   
  16. a1.channels = c1  
  17. a1.sources = r1  
  18. a1.sinks = k1  


客户端/tmp/linux.log文件3G左右,发送给host1。

 

启动:

host2:

[html]  view plain copy
  1. bin/flume-ng agent -c conf -f conf/load-sink1.conf -n a2  

host3:

[html]  view plain copy
  1. bin/flume-ng agent -c conf -f conf/load-sink2.conf -n a2  

host1:

[html]  view plain copy
  1. bin/flume-ng agent -c conf -f conf/load-balance.conf -n a1  

客户端:

[html]  view plain copy
  1. bin/flume-ng agent -c conf -f conf/client.conf -n a1  

 

注意:启动方式最好是从下往上启动。即:先启动host2和host3,然后启动host1,最后启动client。

测试过程中,可以随时将host2或host3停止,过一段时间再启动。

这样,就测试了flume-ng的load-balance和failover功能。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值