Flume Channel
一、Memory Channel
事件将被存储在内存中(指定大小的队列里)
非常适合那些需要高吞吐量且允许数据丢失的场景下
属性说明:
配置项 |
说明 |
type |
memory |
capacity |
默认100 事件存储在信道中的最大数量 the maximum number of events stored in the channel |
transactionCapacity |
默认100 每个事务中的最大事件数 the maximum number of events the channel wile take from a source or give to a sink per transaction |
配置文件basic.conf如下
#给source起名
a1.sources = s1
#给channel起名
a1.channels = c1
#给sink起名
a1.sinks = k1
#配置source
#配置source的类型
a1.sources.s1.type = netcat
#配置监听的主机
a1.sources.s1.bind = 0.0.0.0
#配置监听的端口
a1.sources.s1.port = 8090
#配置channel
#配置channel的类型
a1.channels.c1.type = memory
#配置channel的容量
a1.channels.c1.capacity = 10000
#配置往sink发送的数据量,每次1000条的量发送
al.channels.c1.transactionCapacity = 1000
#配置sink
#配置sink的类型
a1.sinks.k1.type = logger
#将source和channel绑定
a1.sources.s1.channels = c1
#将sink和channel绑定
a1.sinks.k1.channel = c1
bin目录下执行:./flume-ng agent -n a1 -c ../conf/ -f ../data/basic.conf -Dflume.root.logger=INFO,console
二、FileChannel
性能比较低,但是即使程序出错数据不会丢失
性能会比较低下,但是即使程序出错数据不会丢失
配置项 |
说明 |
type |
file |
dataDirs |
~/.flume/file-channel/data 逗号分隔的目录列表,用以存放日志文件。使用单独的磁盘上的多个目录可以提高文件通道效率。 |
配置文件filechannel.conf如下
#给Agent起名为a1
#给source起名
a1.sources = s1
#给channel起名
a1.channels = c1
#给sink起名
a1.sinks = k1
#配置source
#配置source的类型
a1.sources.s1.type = netcat
#配置监听的主机
a1.sources.s1.bind = 0.0.0.0
#配置监听的端口
a1.sources.s1.port = 8090
#配置channel
#配置channel的类型
a1.channels.c1.type = file
#配置数据存储位置
a1.channels.c1.dataDirs = /home/flumefile
#配置channel的容量
a1.channels.c1.capacity = 10000
#配置往sink发送的数据量,每次1000条的量发送
al.channels.c1.transactionCapacity = 1000
#配置sink
#配置sink的类型
a1.sinks.k1.type = logger
#将source和channel绑定
a1.sources.s1.channels = c1
#将sink和channel绑定
a1.sinks.k1.channel = c1
bin目录下执行:./flume-ng agent -n a1 -c ../conf/ -f ../data/filechannel.conf -Dflume.root.logger=INFO,console
三、JDBC Channel
事件会被持久化(存储)到可靠的数据库里,目前支持嵌入式Derby数据库(单连接数据库)。即source=》channel=》sink。
在传输的过程中,会先把事件存到关系型数据库里。但是Derby数据库不太好用,所以JDBC Channel目前仅用于测试,不能用于生产环境。
四、Spillable Memory Channel -- 内存溢出通道
事件被存储在内存队列和磁盘中。内存队列作为主存储,而磁盘作为溢出内容的存储。此通道处于试验阶段,不建议在生产环境中使用