串联的Agent中间采用Avro Sink和 Avro Source方式进行数据传输

image.png

1. Hadoop02配置文件a.conf

采集Hadoop02文件,传输到Hadoop02

  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 = exec
  7. a1.sources.r1.command = cat /home/hadoop/second.txt
  8. # Describe the sink
  9. a1.sinks.k1.type = avro
  10. a1.sinks.k1.hostname = hadoop04
  11. a1.sinks.k1.port = 44444
  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

2. Hadoop04配置文件b.conf

采集Hadoop04文件,传输到hdfs

  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.bind = hadoop04
  8. a1.sources.r1.port = 44444
  9. # Describe the sink
  10. a1.sinks.k1.type = hdfs
  11. a1.sinks.k1.hdfs.path = /a/flume/test_01
  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

3. 启动Hadoop04上的Agent

flume-ng agent --conf conf --conf-file /home/hadoop/kylin/b.conf --name a1

4. 启动Hadoop02上的Agent

flume-ng agent --conf conf --conf-file /home/hadoop/kylin/a.conf --name a1