!!!1.Memory Channel 内存通道
事件将被存储在内存中的具备指定大小的队列中。
很是适合那些须要高吞吐量可是失败是会丢失数据的场景下。
属性说明:
!type – 类型,必须是“memory”
capacity 100 事件存储在信道中的最大数量
transactionCapacity 100 每一个事务中的最大事件数
keep-alive 3 添加或删除操做的超时时间
byteCapacityBufferPercentage 20 Defines the percent of buffer between byteCapacity and the estimated total size of all events in the channel, to account for data in headers. See below.
byteCapacity see description Maximum total bytes of memory allowed as a sum of all events in this channel. The implementation only counts the Event body, which is the reason for providing the byteCapacityBufferPercentage configuration parameter as well. Defaults to a computed value equal to 80% of the maximum memory available to the JVM (i.e. 80% of the -Xmx value passed on the command line). Note that if you have multiple memory channels on a single JVM, and they happen to hold the same physical events (i.e. if you are using a replicating channel selector from a single source) then those event sizes may be double-counted for channel byteCapacity purposes. Setting this value to 0 will cause this value to fall back to a hard internal limit of about 200 GB.
案例:参看入门案例
2.JDBC Channel
事件被持久存储在可靠的数据库中。目前支持嵌入式的Derby数据库。若是可恢复性很是的重要能够使用这种方式。
!!!3.File Channel
性能会比较低下,可是即便程序出错数据不会丢失
属性说明:
!type – 类型,必须是“file”
checkpointDir ~/.flume/file-channel/checkpoint 检查点文件存放的位置
useDualCheckpoints false Backup the checkpoint. If this is set to true, backupCheckpointDir must be set
backupCheckpointDir – The directory where the checkpoint is backed up to. This directory must not be the same as the data directories or the checkpoint directory
dataDirs ~/.flume/file-channel/data 逗号分隔的目录列表,用以存放日志文件。使用单独的磁盘上的多个目录能够提升文件通道效率。
transactionCapacity 10000 The maximum size of transaction supported by the channel
checkpointInterval 30000 Amount of time (in millis) between checkpoints
maxFileSize 2146435071 一个日志文件的最大尺寸
minimumRequiredSpace 524288000 Minimum Required free space (in bytes). To avoid data corruption, File Channel stops accepting take/put requests when free space drops below this value
capacity 1000000 Maximum capacity of the channel
keep-alive 3 Amount of time (in sec) to wait for a put operation
use-log-replay-v1 false Expert: Use old replay logic
use-fast-replay false Expert: Replay without using queue
checkpointOnClose true Controls if a checkpoint is created when the channel is closed. Creating a checkpoint on close speeds up subsequent startup of the file channel by avoiding replay.
encryption.activeKey – Key name used to encrypt new data
encryption.cipherProvider – Cipher provider type, supported types: AESCTRNOPADDING
encryption.keyProvider – Key provider type, supported types: JCEKSFILE
encryption.keyProvider.keyStoreFile – Path to the keystore file
encrpytion.keyProvider.keyStorePasswordFile – Path to the keystore password file
encryption.keyProvider.keys – List of all keys (e.g. history of the activeKey setting)
encyption.keyProvider.keys.*.passwordFile – Path to the optional key password file
!!!4.Spillable Memory Channel -- 内存溢出通道
事件被存储在内存队列和磁盘中。
内存队列做为主存储,而磁盘做为溢出内容的存储。
内存存储经过embedded File channel来进行管理。
当内存队列已满时,后续的事件将被存储在文件通道中。
这个通道适用于正常操做期间适用内存通道已期实现高效吞吐,而在高峰期间适用文件通道实现高耐受性。经过下降吞吐效率提升系统可耐受性。
若是Agent崩溃,则只有存储在文件系统中的事件能够被恢复。
此通道处于试验阶段,不建议在生产环境中使用。
属性说明:
!type – 类型,必须是"SPILLABLEMEMORY"
memoryCapacity 10000 内存中存储事件的最大值,若是想要禁用内存缓冲区将此值设置为0。
overflowCapacity 100000000 能够存储在磁盘中的事件数量最大值。设置为0能够禁用磁盘存储。
overflowTimeout 3 The number of seconds to wait before enabling disk overflow when memory fills up.
byteCapacityBufferPercentage 20 Defines the percent of buffer between byteCapacity and the estimated total size of all events in the channel, to account for data in headers. See below.
byteCapacity see description Maximum bytes of memory allowed as a sum of all events in the memory queue. The implementation only counts the Event body, which is the reason for providing the byteCapacityBufferPercentage configuration parameter as well. Defaults to a computed value equal to 80% of the maximum memory available to the JVM (i.e. 80% of the -Xmx value passed on the command line). Note that if you have multiple memory channels on a single JVM, and they happen to hold the same physical events (i.e. if you are using a replicating channel selector from a single source) then those event sizes may be double-counted for channel byteCapacity purposes. Setting this value to 0 will cause this value to fall back to a hard internal limit of about 200 GB.
avgEventSize 500 Estimated average size of events, in bytes, going into the channel
<file channel properties> see file channel Any file channel property with the exception of ‘keep-alive’ and ‘capacity’ can be used. The keep-alive of file channel is managed by Spillable Memory Channel. Use ‘overflowCapacity’ to set the File channel’s capacity.
5.自定义渠道
自定义渠道须要本身实现Channel接口。
自定义Channle类及其依赖类必须在Flume启动前放置到类加载的目录下。
参数说明:
type - 本身实现的Channle类的全路径名称
----------------------------------------------
课后练习
flume从多个netcat中获取日志
经过Interceptors在事件中增长host信息
经过selector实现多路复用
不一样的ip进行扇出,进入不一样的channel和sink进行发送
存储到本地文件系统 存储到hdfs 存储到logger中
总体结构参看图