Flume - 故障转移、负载均衡

快来打我* 2023-06-09 10:27 74阅读 0赞
  • 故障转移

概述:

故障转移机制的工作方式是将失败的sink放到一个池中,并在池中为它们分配一段冷冻期,在重试之前随着连续的失败而增加。一个sink成功发送event后,将其恢复到活动池。sink有一个与它们相关联的优先级,数字越大表示优先级越高。如果一个sink在发送event时失败,则下一个具有最高优先级的sink将被尝试用于发送事件。

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JsZXNzaW5nWFJZ_size_16_color_FFFFFF_t_70

实例:

  1. # hadoop105
  2. # Name the components on this agent
  3. a1.sources = r1
  4. a1.sinks = k1 k2
  5. a1.channels = c1
  6. a1.sinkgroups = g1
  7. # Describe/configure the source
  8. a1.sources.r1.type = netcat
  9. a1.sources.r1.bind = localhost
  10. a1.sources.r1.port = 44444
  11. # Channel
  12. a1.channels.c1.type = memory
  13. a1.channels.c1.capacity = 1000
  14. a1.channels.c1.transactionCapacity = 100
  15. # Sink
  16. a1.sinks.k1.type = avro
  17. a1.sinks.k1.hostname = hadoop106
  18. a1.sinks.k1.port = 4141
  19. a1.sinks.k2.type = avro
  20. a1.sinks.k2.hostname = hadoop107
  21. a1.sinks.k2.port = 4142
  22. #Sink Group
  23. a1.sinkgroups.g1.sinks = k1 k2
  24. a1.sinkgroups.g1.processor.type = failover
  25. a1.sinkgroups.g1.processor.priority.k1 = 5
  26. a1.sinkgroups.g1.processor.priority.k2 = 10
  27. a1.sinkgroups.g1.processor.maxpenalty = 10000
  28. #Bind
  29. a1.sources.r1.channels = c1
  30. a1.sinks.k1.channel = c1
  31. a1.sinks.k2.channel = c1
  32. ----------------------------------------------------------------------
  33. # hadoop106
  34. #Name
  35. a2.sources = r1
  36. a2.channels = c1
  37. a2.sinks = k1
  38. #Source
  39. a2.sources.r1.type = avro
  40. a2.sources.r1.bind = hadoop106
  41. a2.sources.r1.port = 4141
  42. #Channel
  43. a2.channels.c1.type = memory
  44. a2.channels.c1.capacity = 1000
  45. a2.channels.c1.transactionCapacity = 100
  46. #Sink
  47. a2.sinks.k1.type = logger
  48. #Bind
  49. a2.sources.r1.channels = c1
  50. a2.sinks.k1.channel = c1
  51. ----------------------------------------------------------------------
  52. # hadoop107
  53. #Name
  54. a3.sources = r1
  55. a3.channels = c1
  56. a3.sinks = k1
  57. #Source
  58. a3.sources.r1.type = avro
  59. a3.sources.r1.bind = hadoop107
  60. a3.sources.r1.port = 4142
  61. #Channel
  62. a3.channels.c1.type = memory
  63. a3.channels.c1.capacity = 1000
  64. a3.channels.c1.transactionCapacity = 100
  65. #Sink
  66. a3.sinks.k1.type = logger
  67. #Bind
  68. a3.sources.r1.channels = c1
  69. a3.sinks.k1.channel = c1

参考文章链接:
文章1:http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html
文章2:https://blog.51cto.com/jackwxh/1906893

  • 负载均衡

概述:

source中的event流经channel,进入sink group,在sink group中根据负载算法(round_robin、random)选择sink,然后选择不同机器上的agent实现负载均衡。

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JsZXNzaW5nWFJZ_size_16_color_FFFFFF_t_70 1

  1. # hadoop105
  2. # Name the components on this agent
  3. a1.sources = r1
  4. a1.sinks = k1 k2
  5. a1.channels = c1
  6. a1.sinkgroups = g1
  7. # Describe/configure the source
  8. a1.sources.r1.type = netcat
  9. a1.sources.r1.bind = localhost
  10. a1.sources.r1.port = 44444
  11. # Channel
  12. a1.channels.c1.type = memory
  13. a1.channels.c1.capacity = 1000
  14. a1.channels.c1.transactionCapacity = 100
  15. # Sink
  16. a1.sinks.k1.type = avro
  17. a1.sinks.k1.hostname = hadoop106
  18. a1.sinks.k1.port = 4141
  19. a1.sinks.k2.type = avro
  20. a1.sinks.k2.hostname = hadoop107
  21. a1.sinks.k2.port = 4142
  22. #Sink Group
  23. a1.sinkgroups.g1.sinks = k1 k2
  24. a1.sinkgroups.g1.processor.type = load_balance
  25. a1.sinkgroups.g1.processor.backoff = true
  26. a1.sinkgroups.g1.processor.selector = random
  27. #Bind
  28. a1.sources.r1.channels = c1
  29. a1.sinks.k1.channel = c1
  30. a1.sinks.k2.channel = c1
  31. ----------------------------------------------------------------------
  32. # hadoop106
  33. #Name
  34. a2.sources = r1
  35. a2.channels = c1
  36. a2.sinks = k1
  37. #Source
  38. a2.sources.r1.type = avro
  39. a2.sources.r1.bind = hadoop106
  40. a2.sources.r1.port = 4141
  41. #Channel
  42. a2.channels.c1.type = memory
  43. a2.channels.c1.capacity = 1000
  44. a2.channels.c1.transactionCapacity = 100
  45. #Sink
  46. a2.sinks.k1.type = logger
  47. #Bind
  48. a2.sources.r1.channels = c1
  49. a2.sinks.k1.channel = c1
  50. ----------------------------------------------------------------------
  51. # hadoop107
  52. #Name
  53. a3.sources = r1
  54. a3.channels = c1
  55. a3.sinks = k1
  56. #Source
  57. a3.sources.r1.type = avro
  58. a3.sources.r1.bind = hadoop107
  59. a3.sources.r1.port = 4142
  60. #Channel
  61. a3.channels.c1.type = memory
  62. a3.channels.c1.capacity = 1000
  63. a3.channels.c1.transactionCapacity = 100
  64. #Sink
  65. a3.sinks.k1.type = logger
  66. #Bind
  67. a3.sources.r1.channels = c1
  68. a3.sinks.k1.channel = c1

参考文章地址:
文章1:http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html
文章2:https://blog.csdn.net/silentwolfyh/article/details/51165804

发表评论

表情:
评论列表 (有 0 条评论,74人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Flume ——故障转移

    Sink groups允许组织多个sink到一个实体上。 Sink processors能够提供在组内所有Sink之间实现负载均衡的能力,而且在失败的情况下能够进行故障转移从一