Time for action – multi level Flume networks

Let's put together a few pieces we touched on earlier and see how one Flume agent can use another as its sink.

  1. Create the following file as agent6.conf:
    agent6.sources = avrosource
    agent6.sinks = avrosink
    agent6.channels = memorychannel
    
    agent6.sources.avrosource.type = avro
    agent6.sources.avrosource.bind = localhost
    agent6.sources.avrosource.port = 2000
    agent6.sources.avrosource.threads = 5
    
    agent6.sinks.avrosink.type = avro
    agent6.sinks.avrosink.hostname = localhost
    agent6.sinks.avrosink.port = 4000
    
    agent6.channels.memorychannel.type = memory
    agent6.channels.memorychannel.capacity = 1000
    agent6.channels.memorychannel.transactionCapacity = 100
    
    agent6.sources.avrosource.channels = memorychannel
    agent6.sinks.avrosink.channel = memorychannel
  2. Start an agent configured as per the agent3.conf file created earlier, that is, with an Avro source and a file sink:
    $ flume-ng client –conf conf –conf-file agent3.conf agent3  
    
  3. In a second window, start another agent; this one configured with the preceding file:
    $ flume-ng client –conf conf –conf-file agent6.conf agent6
    
  4. In a third window, use the Avro client to send a file to each of the Flume agents:
    $ flume-ng avro-client –H localhost –p 4000 –F /home/hadoop/message
    $ flume-ng avro-client -H localhost -p 2000 -F /home/hadoop/message2
    
  5. Check the output directory for files and examine the file present:
    Time for action – multi level Flume networks

What just happened?

Firstly, we defined a new agent with an Avro source and also an Avro sink. We've not used this sink before; instead of writing the events to a local location or HDFS, this sink sends the events to a remote source using Avro.

We start an instance of this new agent and then also start an instance of agent3 we used earlier. Recall this agent has an Avro source and a file roll sink. We configure the Avro sink in the first agent to point to the host and port of the Avro sink in the second and by doing so, build a data-routing chain.

With both agents running, we then use the Avro client to send a file to each and confirm that both appear in the file location configured as the destination for the agent3 sink.

This isn't just technical capability for its own sake. This capability is the building block that allows Flume to build arbitrarily complex distributed event collection networks. Instead of one copy of each agent, think of multiple agents of each type feeding events into the next link in the chain, which acts as an event aggregation point.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189