What is Flume?
Apache Flume is a highly reliable, highly available distributed mass log collection, aggregation, and transmission system. It can collect data from different log sources and store it centrally.
Flume is also part of the Hadoop ecosystem, originating in Cloudera, and is currently one of the top projects of the Apache Foundation. Flume has two product lines, 0.9.x version and 1.x version.
Official website: http://flume.appache.org/
- Distributed framework for collecting and aggregating event stream data
- Typically used for log data
- With the AD-HOC scheme, the obvious advantages are as follows:
- Reliable, scalable, manageable, customizable, high performance
- Declarative configuration, which dynamically updates the configuration
- Provides context routing capabilities
- Support for load balancing and failover
- Feature Rich
- Fully extensible
Core Concepts
- Event
- Client
- Agent
- Sources, Channels, Sinks
- Other components: Interceptors, Channel selectors, Sink Processor
Core concept: Event
Event is the basic unit of Flume data transfer. Flume the data from the source to the final destination in the form of an event. The event is comprised of an optional hearders and a byte array containing the data.
- The data contained is opaque to flume.
- Headers is an unordered collection of key-value string pairs, and key is unique within the collection.
- Headers can use extensions in context routing
1 Public InterfaceEvent {2 PublicMap<string, string>getheaders (); 3 Public voidSetheaders (map<string, string>headers); 4 Public byte[] GetBody (); 5 Public voidSetbody (byte[] body); 6}
1 Public InterfaceEvent {2 PublicMap<string, string>getheaders (); 3 Public voidSetheaders (map<string, string>headers); 4 Public byte[] GetBody (); 5 Public voidSetbody (byte[] body); 6}
Core concept: Client
Clinet is an entity that wraps the original log into events and sends them to one or more agents.
- For example, to decouple flume from the data source system
- Flume log4j Appender
- You can use the client SDK (ORG.APACHE.FLUME.API) to customize specific client
- Not required in the flume topology
Core concept: Agent
An agent contains sources, Channels, sinks, and other components that use these components to transfer events from one node to another or to the ultimate purpose.
- The agent is the basic part of the flume stream.
- Flume provides configuration, lifecycle management, and monitoring support for these components.
Core concept: Source
Source is responsible for receiving events or generating events through special mechanisms and placing events in batches into one or more channels. There are event drivers and polling for 2 types of source
- Different types of source:source must be associated with at least one channel
- And the well-known system integration of Sources:syslog, Netcat
- Auto-Generate event sources:exec, SEQ
- IPC Sources:avro for communication between agent and agent
Core concept: Channel
The channel is between source and sink and is used to cache incoming events, and events are removed from the channel when sink successfully sends events to the next-hop channel or end purpose.
- The persistence levels offered by different channels are not the same: Channels support transactions
- Memory Channel:volatile
- File Channel: Based on the Wal (pre-write log write-ahead Logging) implementation
- JDBC Channel: Based on embedded database implementation
- Provides a weaker order guarantee
- Can work with any number of source and sink
Core concept: Sink
The sink is responsible for transferring events to the next hop or final purpose, and then removing events from the channel after successful completion.
- Different types of sinks: must function with an exact channel
- The terminal sink that stores events to its final destination. For example: HDFS, HBase
- Automatic consumption of sinks. For example: Null Sink
- IPC Sink:avro for inter-agent communication
Flow Reliability
- Reliability is based on:
- Exchange of inter-agent transactions
- The long-lasting characteristics of channel in flow
- Availability of:
- Built-in load balancing support
- Built-in Failover support
Core Concept: Interceptor
A set of interceptor used for source to decorate and filter events where necessary in a predetermined order.
- The built-in interceptors allows to increase the headers of the event such as timestamp, hostname, static tag, etc.
- Custom interceptors can create a specific headers where necessary by introspective event payload (reading the original log).
Core concept: Channel Selector
Channel Selector allows source to select one or more channel from all channel based on preset criteria
- Built-in channel selectors:
- Replication Replicating:event are copied to the relevant channel
- Multiplexing multiplexing: Based on Hearder,event being routed to a specific channel
Core concept: Sink Processor
multiple sink can form a sink Group. A sink processor is responsible for activating a sink from a specified sink group. Sink processor can be load balanced across all Sink in a group, or it can be transferred to another when one Sink fails.
- Flume load balancing (load balancing) and failover via sink processor (failover)
- Built-in sink processors: All sink take the polling (polling) way to get events from the channel. This action was activated by sink runner.
- Load balancing Sink processor– using random, Round_robin or custom selection algorithms
- Failover Sink Processor
- Default Sink Processor (single Sink)
- Sink processor acts as a proxy for Sink
Summary
Transferred from: http://blog.csdn.net/szwangdf/article/details/33275351
Appache Flume Chinese Introduction (Turn)