我是靠谱客的博主 文静金毛,最近开发中收集的这篇文章主要介绍flume-ng负载均衡load-balance、failover集群搭建,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

转自:http://blog.csdn.net/morning_pig/article/details/9093149

集群采用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功能。


最后

以上就是文静金毛为你收集整理的flume-ng负载均衡load-balance、failover集群搭建的全部内容,希望文章能够帮你解决flume-ng负载均衡load-balance、failover集群搭建所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部