Flume Channels简介及官方用例
通道是在代理上暂存事件的存储库。Source 添加事件,Sink 将其删除。
1、Memory Channel
事件存储在具有可配置最大大小的内存中队列中。它非常适合需要更高吞吐量的流,但在agent发生故障时会丢失暂存数据
Property Name | Default | Description |
type | – | The component type name, needs to be memory |
Example for agent named a1:
a1.channels = c1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 10000
a1.channels.c1.byteCapacityBufferPercentage = 20
a1.channels.c1.byteCapacity = 800000
2、JDBC Channel.
事件存储在由数据库支持的持久性存储中。JDBC 通道目前支持嵌入式 Derby。这是一个持久的通道,非常适合可恢复性很重要的流。
Property Name | Default | Description |
type | – | The component type name, needs to be jdbc |
Example for agent named a1:
a1.channels = c1
a1.channels.c1.type = jdbc
3、Kafka Channel
提供高可用性和复制,因此,如果agent或 Kafka 崩溃,这些事件会立即提供给其他sink
Kafka 通道可用于多种方案:
1. 使用 Flume source和sink器 - 它为事件提供了一个可靠且高度可用的通道
2. 使用 Flume source和interceptor,但没有sink - 它允许将 Flume 事件写入 Kafka topic,供其他应用程序使用
3. 使用 Flume sink,但没有source - 这是一种低延迟、容错的方式,可以将事件从 Kafka 发送到 Flume sink,例如 HDFS、HBase 或 Solr
目前支持 Kafka 服务器版本 0.10.1.0 或更高版本。测试完成到 2.0.1,这是发布时最高的可用版本。
配置参数的组织方式如下
1. 与通道相关的配置值一般应用于通道配置级别,例如:a1.channel.k1.type =
2. 与 Kafka 或通道运行方式相关的配置值以“kafka”为前缀(这与 CommonClient 配置无关),例如:a1.channels.k1.kafka.topic 和 a1.channels.k1.kafka.bootstrap.servers。这与 hdfs 接收器的运行方式没有什么不同
3. 特定于生产者/消费者的属性以 kafka.producer 或 kafka.consumer 为前缀
4. 在可能的情况下,使用 Kafka 参数名称,例如:bootstrap.servers 和 acks
Property Name | Default | Description |
type | – | The component type name, needs to be org.apache.flume.channel.kafka.KafkaChannel |
kafka.bootstrap.servers | – | List of brokers in the Kafka cluster used by the channel This can be a partial list of brokers, but we recommend at least two for HA. The format is comma separated list of hostname:port |
Example for agent named a1:
a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9092,kafka-2:9092,kafka-3:9092
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer
4、File Channel
默认情况下,文件通道使用用户主目录内的检查点和数据目录的路径。因此,如果代理中有多个文件通道实例处于活动状态,则只有一个实例能够锁定目录并导致另一个通道初始化失败。因此,有必要提供所有已配置通道的显式路径,最好是在不同的磁盘上。此外,由于文件通道将在每次提交后同步到磁盘,因此可能需要将其与将事件批处理在一起的接收器/源耦合,以便在多个磁盘不可用于检查点和数据目录的情况下提供良好的性能。
Property Name Default | Description |
|
type | – | The component type name, needs to be file. |
Example for agent named a1:
a1.channels = c1
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /mnt/flume/checkpoint
a1.channels.c1.dataDirs = /mnt/flume/data