image.png

    1. 使用Flume1监控一个端口,其sink组中的sink分别对接Flume2Flume3,采用FailoverSinkProcessor,实现故障转移的功能
    2. mkdir -p /opt/egg/apache-flume-1.7.0-bin/group2
    3. 1sink group2sink),分别输送给flume-flume-console1flume-flume-console2
    4. vim flume-netcat-flume.conf
    5. # Name the components on this agent
    6. a1.sources = r1
    7. a1.channels = c1
    8. a1.sinkgroups = g1
    9. a1.sinks = k1 k2
    10. # Describe/configure the source
    11. a1.sources.r1.type = netcat
    12. a1.sources.r1.bind = localhost
    13. a1.sources.r1.port = 44444
    14. a1.sinkgroups.g1.processor.type = failover
    15. a1.sinkgroups.g1.processor.priority.k1 = 5
    16. a1.sinkgroups.g1.processor.priority.k2 = 10
    17. a1.sinkgroups.g1.processor.maxpenalty = 10000
    18. # Describe the sink
    19. a1.sinks.k1.type = avro
    20. a1.sinks.k1.hostname = hadoop1
    21. a1.sinks.k1.port = 4141
    22. a1.sinks.k2.type = avro
    23. a1.sinks.k2.hostname = hadoop1
    24. a1.sinks.k2.port = 4142
    25. # Describe the channel
    26. a1.channels.c1.type = memory
    27. a1.channels.c1.capacity = 1000
    28. a1.channels.c1.transactionCapacity = 100
    29. # Bind the source and sink to the channel
    30. a1.sources.r1.channels = c1
    31. a1.sinkgroups.g1.sinks = k1 k2
    32. a1.sinks.k1.channel = c1
    33. a1.sinks.k2.channel = c1
    34. 输出是到本地控制台
    35. vim flume-flume-console1.conf
    36. # Name the components on this agent
    37. a2.sources = r1
    38. a2.sinks = k1
    39. a2.channels = c1
    40. # Describe/configure the source
    41. a2.sources.r1.type = avro
    42. a2.sources.r1.bind = hadoop1
    43. a2.sources.r1.port = 4141
    44. # Describe the sink
    45. a2.sinks.k1.type = logger
    46. # Describe the channel
    47. a2.channels.c1.type = memory
    48. a2.channels.c1.capacity = 1000
    49. a2.channels.c1.transactionCapacity = 100
    50. # Bind the source and sink to the channel
    51. a2.sources.r1.channels = c1
    52. a2.sinks.k1.channel = c1
    53. 输出是到本地控制台。
    54. vim flume-flume-console2.conf
    55. # Name the components on this agent
    56. a3.sources = r1
    57. a3.sinks = k1
    58. a3.channels = c2
    59. # Describe/configure the source
    60. a3.sources.r1.type = avro
    61. a3.sources.r1.bind = hadoop1
    62. a3.sources.r1.port = 4142
    63. # Describe the sink
    64. a3.sinks.k1.type = logger
    65. # Describe the channel
    66. a3.channels.c2.type = memory
    67. a3.channels.c2.capacity = 1000
    68. a3.channels.c2.transactionCapacity = 100
    69. # Bind the source and sink to the channel
    70. a3.sources.r1.channels = c2
    71. a3.sinks.k1.channel = c2
    72. 启动flume
    73. bin/flume-ng agent --conf conf/ --name a3 --conf-file job/group2/flume-flume-console2.conf -Dflume.root.logger=INFO,console
    74. bin/flume-ng agent --conf conf/ --name a2 --conf-file job/group2/flume-flume-console1.conf -Dflume.root.logger=INFO,console
    75. bin/flume-ng agent --conf conf/ --name a1 --conf-file job/group2/flume-netcat-flume.conf
    76. 44444端口发送字符串
    77. nc localhost 44444