分享

flume的负载均衡load balancer

 louy2 2019-02-26

三台机器规划如下:

node01:采集数据,发送到node02和node03机器上去

node02:接收node01的部分数据

node03:接收node01的部分数据

第一步:开发node01服务器的flume配置

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf

vim load_banlancer_client.conf

  1. #agent name
  2. a1.channels = c1
  3. a1.sources = r1
  4. a1.sinks = k1 k2
  5. #set gruop
  6. a1.sinkgroups = g1
  7. #set channel
  8. a1.channels.c1.type = memory
  9. a1.channels.c1.capacity = 1000
  10. a1.channels.c1.transactionCapacity = 100
  11. a1.sources.r1.channels = c1
  12. a1.sources.r1.type = exec
  13. a1.sources.r1.command = tail -F /export/servers/taillogs/access_log
  14. # set sink1
  15. a1.sinks.k1.channel = c1
  16. a1.sinks.k1.type = avro
  17. a1.sinks.k1.hostname = node02
  18. a1.sinks.k1.port = 52020
  19. # set sink2
  20. a1.sinks.k2.channel = c1
  21. a1.sinks.k2.type = avro
  22. a1.sinks.k2.hostname = node03
  23. a1.sinks.k2.port = 52020
  24. #set sink group
  25. a1.sinkgroups.g1.sinks = k1 k2
  26. #set failover
  27. a1.sinkgroups.g1.processor.type = load_balance
  28. a1.sinkgroups.g1.processor.backoff = true
  29. a1.sinkgroups.g1.processor.selector = round_robin
  30. a1.sinkgroups.g1.processor.selector.maxTimeOut=10000

第二步:开发node02服务器的flume配置

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf

vim load_banlancer_server.conf

  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = node02
  9. a1.sources.r1.port = 52020
  10. # Describe the sink
  11. a1.sinks.k1.type = logger
  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100
  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1

第三步:开发node03服务器flume配置

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin/conf

vim load_banlancer_server.conf

  1. # Name the components on this agent
  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1
  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = node03
  9. a1.sources.r1.port = 52020
  10. # Describe the sink
  11. a1.sinks.k1.type = logger
  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100
  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1

第四步:准备启动flume服务

启动node03的flume服务

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin

bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger=DEBUG,console

启动node02的flume服务

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin

bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger=DEBUG,console

启动node01的flume服务

cd /export/servers/apache-flume-1.6.0-cdh5.14.0-bin

bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_client.conf -Dflume.root.logger=DEBUG,console

第五步:node01服务器运行脚本产生数据

cd /export/servers/shells

sh tail-file.sh

Flume支持众多的source和sink类型,详细手册可参考官方文档

http://archive./cdh5/cdh/5/flume-ng-1.6.0-cdh5.14.0/FlumeUserGuide.html

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多