flume安裝使用教程

1.     flume概述

1.1.         flume概念

1.1.1. flume概念

flume是分佈式的,可靠的,高可用的,用於對不同來源的大量的日誌數據進行有效收集、聚集和移動,並以集中式的數據存儲的系統。

flume目前是apache的一個頂級項目。

1.1.2. 系統需求

flume需要java運行環境,要求java1.6以上.

1.2.         下載安裝flume

1.2.1. 下載flume:

可以到apache官網下載flume的安裝包。

下載時需要注意,flume具有兩個版本:0.9.x和1.x,這裏使用的是1.x版本,也叫flume-ng版本。

1.2.2. 安裝flume:

將下載好的flume安裝包解壓到指定目錄即可。

2.     flume中的概念、模型和特點

2.1.         flume中的一些重要概念

2.1.1.     flume Event:

flume 事件,被定義爲一個具有有效荷載的字節數據流和可選的字符串屬性集。

2.1.2.     flume Agent:

flume 代理,是一個進程承載從外部源事件流到下一個目的地的過程。包含source channel 和 sink。

2.1.3.     Source

數據源,消耗外部傳遞給他的事件,外部源將數據按照flume Source 能識別的格式將Flume 事件發送給flumeSource。

2.1.4.     Channel

數據通道,是一個被動的存儲,用來保持事件,直到由一個flume Sink消耗。

2.1.5.     Sink

數據匯聚點,代表外部數據存放位置。發送flume event到指定的外部目標。

2.2.     flume流動模型


 

2.3.     flume的特點

2.3.1. 複雜流動性

Flume允許用戶進行多級流動到最終目的地,也允許扇出流(一到多)、扇入流(多到一)的、故障轉移和失敗處理。

2.3.2. 可靠性

事務性的數據傳遞,保證了數據的可靠性。

2.3.3. 可恢復性

通道可以以內存或文件的方式實現,內存更快,但是不可恢復,而文件雖然比較慢但提供了可恢復性。

 

3.     入門案例

 

3.1.  編寫配置文件

首先需要通過一個配置文件來配置Agent。

       #example.conf:單節點Flume配置

       #命名Agent a1的組件

       a1.sources  =  r1

       a1.sinks  =  k1

       a1.channels  =  c1

 

       #描述/配置Source

       a1.sources.r1.type  = netcat

       a1.sources.r1.bind  = 0.0.0.0

       a1.sources.r1.port  = 44444

 

       #描述Sink

        a1.sinks.k1.type  = logger

 

       #描述內存Channel

       a1.channels.c1.type  = memory

       a1.channels.c1.capacity  =  1000

       a1.channels.c1.transactionCapacity  =  100

 

       #爲Channle綁定Source和Sink

       a1.sources.r1.channels  =  c1

       a1.sinks.k1.channel  =  c1

注意:

(1)一個配置文件中可以配置多個Agent,一個Agent中可以包含多個Source、Sink、Channel。

(2)一個Source 可以綁定到多個通道,但一個Sink只能綁定到一個通道。

3.2. 通過flume的工具啓動agent

$ bin/flume-ng agent --conf conf--conf-file example.conf --name a1 -Dflume.root.logger=INFO,console

3.3.  發送數據

在windows中通過telnet命令連接flume所在機器的44444端口發送數據。

發現,flume確實收集到了該信息。

 

4.     Source詳解

4.1. Avro Source

4.1.1.  Avro Source 概述

監聽AVRO端口來接受來自外部AVRO客戶端的事件流。

利用Avro Source可以實現多級流動、扇出流、扇入流等效果。

另外也可以接受通過flume提供的Avro客戶端發送的日誌信息。

4.1.2.  Avro Source屬性說明

!channels  –  

!type  –   類型名稱,"AVRO"

!bind  –   需要監聽的主機名或IP

!port  –   要監聽的端口

threads    –   工作線程最大線程數

selector.type     

selector.*     

interceptors  –   空格分隔的攔截器列表

interceptors.*        

compression-type  none   壓縮類型,可以是“none”或“default”,這個值必須和AvroSource的壓縮格式匹配

ssl false  是否啓用ssl加密,如果啓用還需要配置一個“keystore”和一個“keystore-password”。

keystore   –   爲SSL提供的java密鑰文件所在路徑。

keystore-password –   爲SSL提供的java密鑰文件 密碼。

keystore-type JKS 密鑰庫類型可以是“JKS”或“PKCS12”。

exclude-protocols SSLv3  空格分隔開的列表,用來指定在SSL / TLS協議中排除。SSLv3將總是被排除除了所指定的協議。

ipFilter   false  如果需要爲netty開啓ip過濾,將此項設置爲true

ipFilterRules –   定義netty的ip過濾設置表達式規則

4.1.3.  案例

編寫配置文件:

    #命名Agent a1的組件

    a1.sources  =  r1

    a1.sinks  =  k1

    a1.channels  =  c1

 

    #描述/配置Source

    a1.sources.r1.type  =  avro

    a1.sources.r1.bind  = 0.0.0.0

    a1.sources.r1.port  = 33333

 

    #描述Sink

    a1.sinks.k1.type  = logger

    #描述內存Channel

    a1.channels.c1.type  = memory

    a1.channels.c1.capacity  =  1000

    a1.channels.c1.transactionCapacity  =  100

 

    #爲Channle綁定Source和Sink

    a1.sources.r1.channels  =  c1

    a1.sinks.k1.channel  =  c1

 

啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template2.conf --name a1 -Dflume.root.logger=INFO,console

 

通過flume提供的avro客戶端向指定機器指定端口發送日誌信息:

    ./flume-ngavro-client --conf ../conf --host 0.0.0.0 --port 33333 --filename../mydata/log1.txt

 

發現確實收集到了日誌。

4.2. Exec Source

4.2.1.  Exec Source概述

可以將命令產生的輸出作爲源。

4.2.2.  Exec Source屬性說明

!channels  –  

!type  –   類型名稱,需要是"exec"

!command   –   要執行的命令

shell  –   Ashell invocation used to run the command. e.g. /bin/sh -c. Required only forcommands relying on shell features like wildcards, back ticks, pipes etc.

restartThrottle   10000  毫秒爲單位的時間,用來聲明等待多久後嘗試重試命令

restart    false  如果cmd掛了,是否重啓cmd

logStdErr  false  無論是否是標準錯誤都該被記錄

batchSize  20  同時發送到通道中的最大行數

batchTimeout  3000   如果緩衝區沒有滿,經過多長時間發送  數據

selector.type 複製還是多路複用

selector.*    Depends on the selector.type value

interceptors  –   空格分隔的攔截器列表

interceptors.*

 

4.2.3.  案例

編寫配置文件:

    #命名Agent a1的組件

    a1.sources =  r1

    a1.sinks =  k1

    a1.channels =  c1

 

    #描述/配置Source

    a1.sources.r1.type  =  avro

    a1.sources.r1.bind  = 0.0.0.0

    a1.sources.r1.port  = 33333

 

    #描述Sink

    a1.sinks.k1.type  = logger

    #描述內存Channel

    a1.channels.c1.type  = memory

    a1.channels.c1.capacity  =  1000

    a1.channels.c1.transactionCapacity  =  100

 

    #爲Channle綁定Source和Sink

    a1.sources.r1.channels  =  c1

    a1.sinks.k1.channel  =  c1

 

啓動flume:

    ./flume-ng agent --conf ../conf --conf-file../conf/template2.conf --name a1 -Dflume.root.logger=INFO,console

 

可以通過tail命令,收集日誌文件中後續追加的日誌

4.3. Spooling Directory Source

4.3.1.  Spooling Directory Source概述

這個Source允許你將將要收集的數據放置到"自動蒐集"目錄中。這個Source將監視該目錄,並將解析新文件的出現。事件處理邏輯是可插拔的,當一個文件被完全讀入通道,它會被重命名或可選的直接刪除。

要注意的是,放置到自動蒐集目錄下的文件不能修改,如果修改,則flume會報錯。另外,也不能產生重名的文件,如果有重名的文件被放置進來,則flume會報錯。

4.3.2.  Spooling Directory Source屬性說明

!channels  –  

!type  –   類型,需要指定爲"spooldir"

!spoolDir  –   讀取文件的路徑,即"蒐集目錄"

fileSuffix .COMPLETED 對處理完成的文件追加的後綴

deletePolicy  never  處理完成後是否刪除文件,需是"never"或"immediate"

fileHeader false  是否添加一個存儲的絕對路徑名的頭文件.

fileHeaderKey file   Headerkey to use when appending absolute path filename to event header.

basenameHeader    false  Whetherto add a header storing the basename of the file.

basenameHeaderKey basename   HeaderKey to use when appending basename of file to event header.

ignorePattern ^$  正則表達式指定哪些文件需要忽略

trackerDir .flumespool   Directoryto store metadata related to processing of files. If this path is not anabsolute path, then it is interpreted as relative to the spoolDir.

consumeOrder  處理文件的策略,oldest, youngest 或 random。

maxBackoff 4000   Themaximum time (in millis) to wait between consecutive attempts to write to thechannel(s) if the channel is full. The source will start at a low backoff andincrease it exponentially each time the channel throws a ChannelException, uptothe value specified by this parameter.

batchSize  100 Granularityat which to batch transfer to the channel

inputCharset  UTF-8  讀取文件時使用的編碼。

decodeErrorPolicy FAIL   當在輸入文件中發現無法處理的字符編碼時如何處理。FAIL:拋出一個異常而無法 ​​解析該文件。REPLACE:用“替換字符”字符,通常是Unicode的U + FFFD更換不可解析角色。忽略:掉落的不可解析的字符序列。

deserializer  LINE   聲明用來將文件解析爲事件的解析器。默認一行爲一個事件。處理類必須實現EventDeserializer.Builder接口。

deserializer.*       Variesper event deserializer.

bufferMaxLines    –   (Obselete) This option isnow ignored.

bufferMaxLineLength  5000   (Deprecated)Maximum length of a line in the commit buffer. Use deserializer.maxLineLengthinstead.

selector.type replicating   replicatingor multiplexing

selector.*    Dependson the selector.type value

interceptors  –   Space-separated list ofinterceptors

interceptors.*

4.3.3.  案例

編寫配置文件:

#命名Agent a1的組件

a1.sources  =  r1

a1.sinks  =  k1

a1.channels  =  c1

 

#描述/配置Source

a1.sources.r1.type  = spooldir

a1.sources.r1.spoolDir=/home/park/work/apache-flume-1.6.0-bin/mydata

 

#描述Sink

a1.sinks.k1.type  = logger

#描述內存Channel

a1.channels.c1.type  = memory

a1.channels.c1.capacity  =  1000

a1.channels.c1.transactionCapacity  =  100

 

#爲Channle綁定Source和Sink

a1.sources.r1.channels  =  c1

a1.sinks.k1.channel  =  c1

 

啓動flume:

    ./flume-ng agent --conf ../conf --conf-file../conf/template4.conf --name a1 -Dflume.root.logger=INFO,console

 

向指定目錄中傳輸文件,發現flume收集到了該文件,將文件中的每一行都作爲日誌來處理。

4.4. NetCat Source

4.4.1.  NetCat Source概述

一個NetCatSource用來監聽一個指定端口,並將接收到的數據的每一行轉換爲一個事件。

 

4.4.2.  NetCat Source屬性說明

!channels –  

!type –   類型名稱,需要被設置爲"netcat"

!bind –   指定要綁定到的ip或主機名。

!port –   指定要綁定到的端口號

max-line-length   512 單行最大字節數

ack-every-event   true   對於收到的每一個Event是否響應"OK"

selector.type

selector.*   

interceptors  –  

interceptors.*

 

4.4.3.  案例

參見入門案例。

4.5. Sequence Generator Source

 

4.5.1.  Sequence Generator Source概述

一個簡單的序列發生器,不斷的產生事件,值是從0開始每次遞增1。

主要用來進行測試。

4.5.2.  Sequence Generator Source屬性說明

!channels  –  

!type  –   類型名稱,必須爲"seq"

selector.type   

selector.*

interceptors  –  

interceptors.*        

batchSize

4.5.3.  案例

編寫配置文件:

    #命名Agent a1的組件

    a1.sources  =  r1

    a1.sinks  =  k1

    a1.channels  =  c1

 

    #描述/配置Source

    a1.sources.r1.type  = seq

 

    #描述Sink

    a1.sinks.k1.type  = logger

    #描述內存Channel

    a1.channels.c1.type  = memory

    a1.channels.c1.capacity  =  1000

    a1.channels.c1.transactionCapacity  =  100

 

    #爲Channle綁定Source和Sink

    a1.sources.r1.channels  =  c1

    a1.sinks.k1.channel  =  c1

 

啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template4.conf --name a1-Dflume.root.logger=INFO,console

 

發現打印了日誌

4.6. HTTP Source

4.6.1.  HTTP Source概述

HTTP Source接受HTTP的GET和POST請求作爲Flume的事件,其中GET方式應該只用於試驗。

該Source需要提供一個可插拔的"處理器"來將請求轉換爲事件對象,這個處理器必須實現HTTPSourceHandler接口,該處理器接受一個 HttpServletRequest對象,並返回一個Flume Envent對象集合。

從一個HTTP請求中得到的事件將在一個事務中提交到通道中。因此允許像文件通道那樣對通道提高效率。

如果處理器拋出一個異常,Source將會返回一個400的HTTP狀態碼。

如果通道已滿,無法再將Event加入Channel,則Source返回503的HTTP狀態碼,表示暫時不可用。

4.6.2.  HTTP Source屬性說明

!type    類型,必須爲"HTTP"

!port –   監聽的端口

bind   0.0.0.0    監聽的主機名或ip

handler     org.apache.flume.source.http.JSONHandler處理器類,需要實現HTTPSourceHandler接口

handler.*  –   處理器的配置參數

selector.type

selector.*   

interceptors  –  

interceptors.*        

enableSSL  false  是否開啓SSL,如果需要設置爲true。注意,HTTP不支持SSLv3。

excludeProtocols  SSLv3  空格分隔的要排除的SSL/TLS協議。SSLv3總是被排除的。

keystore      密鑰庫文件所在位置。

keystorePasswordKeystore 密鑰庫密碼

4.6.3.  案例

編寫配置文件:

    #命名Agent a1的組件

    a1.sources  =  r1

    a1.sinks  =  k1

    a1.channels  =  c1

 

    #描述/配置Source

    a1.sources.r1.type  = http

    a1.sources.r1.port  = 66666

 

    #描述Sink

    a1.sinks.k1.type  = logger

    #描述內存Channel

    a1.channels.c1.type  = memory

    a1.channels.c1.capacity  =  1000

    a1.channels.c1.transactionCapacity  =  100

 

    #爲Channle綁定Source和Sink

    a1.sources.r1.channels  =  c1

    a1.sinks.k1.channel  =  c1

 

啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template6.conf --name a1-Dflume.root.logger=INFO,console

 

通過命令發送HTTP請求到指定端口:

    curl-X POST -d '[{ "headers" :{"a" :"a1","b" : "b1"},"body" :"hello~http~flume~"}]' http://0.0.0.0:6666

發現flume收集到了日誌

4.6.4.  常用的Handler

JSONHandler

    可以處理JSON格式的數據,並支持UTF-8 UTF-16 UTF-32字符集,該handler接受Evnet數組,並根據請求頭中指定的編碼將其轉換爲Flume Event。

    如果沒有指定編碼,默認編碼爲UTF-8.

    JSON格式如下:

       --

       [{

           "headers": {

                 "timestamp" :"434324343",

                 "host" :"random_host.example.com"

           },

           "body": "random_body"

         },

         {

           "headers": {

                   "namenode" :"namenode.example.com",

                   "datanode" :"random_datanode.example.com"

           },

           "body": "really_random_body"

       }]

       --

    設置字符集時,請求必須包含content type   並設置爲application/json;charset=UTF-8。

    Toset the charset, the request must have content type specified asapplication/json;charset=UTF-8 (replace UTF-8 with UTF-16 or UTF-32 asrequired).

           Oneway to create an event in the format expected by this handler is to useJSONEvent provided in the Flume SDK and use Google Gson to create the JSONstring using the Gson#fromJson(Object, Type) method.

           Typetype=newTypeToken<List<JSONEvent>>(){}.getType();

 

BlobHandler

    BlobHandler是一種將請求中上傳文件信息轉化爲event的處理器。

    參數說明,加!爲必須屬性:

       !handler  –   TheFQCN of this class: org.apache.flume.sink.solr.morphline.BlobHandler

       handler.maxBlobLength    100000000  Themaximum number of bytes to read and buffer for a given request

4.7. Custom source

4.7.1.  Custom source概述

自定義源是自己實現源接口得到的,自定義源的類和其依賴包必須在開始時就放置到Flume的類加載目錄下。

4.7.2.  Custom source屬性說明

!channels –  

!type –   類型,必須設置爲自己的自定義處理類的全路徑名

selector.type   

elector.* 

interceptors  –  

interceptors.*

 

5.     Sink詳解

5.1. Logger Sink

5.1.1. Logger Sink概述

記錄INFO級別的日誌,通常用於調試。

5.1.2. Logger Sink屬性說明

!channel   –  

!type  –   Thecomponent type name, needs to be logger

maxBytesToLog 16  Maximum number of bytes ofthe Event body to log

 

要求必須在 --conf 參數指定的目錄下有 log4j的配置文件

也可以通過-Dflume.root.logger=INFO,console在命令啓動時手動指定log4j參數

5.1.3. 案例

參見入門案例。

 

 

5.2. File Roll Sink

 

5.2.1. File Roll Sink概述

在本地文件系統中存儲事件,每隔指定時長生成文件保存這段時間內收集到的日誌信息。

 

5.2.2. File Roll Sink屬性說明

!channel   –  

!type  –   類型,必須是"file_roll"

!sink.directory   –   文件被存儲的目錄

sink.rollInterval 30  滾動文件每隔30秒(應該是每隔30秒鐘單獨切割數據到一個文件的意思)。如果設置爲0,則禁止滾動,從而導致所有數據被寫入到一個文件中。

sink.serializer   TEXT   Other possible optionsinclude avro_event or the FQCN of an implementation of EventSerializer.Builderinterface.

batchSize  100

 

5.2.3. 案例

編寫配置文件:

#命名Agent a1的組件

a1.sources =  r1

a1.sinks =  k1

a1.channels =  c1

 

#描述/配置Source

a1.sources.r1.type = http

a1.sources.r1.port = 6666

 

#描述Sink

a1.sinks.k1.type = file_roll

a1.sinks.k1.sink.directory=/home/park/work/apache-flume-1.6.0-bin/mysink(修改:之前是a1.sinks.k1.dirctory,出不來結果)

 

#描述內存Channel

a1.channels.c1.type =  memory

a1.channels.c1.capacity  =  1000

a1.channels.c1.transactionCapacity  =  100

 

#爲Channle綁定Source和Sink

a1.sources.r1.channels  =  c1

a1.sinks.k1.channel =  c1

 

啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template7.conf --name a1-Dflume.root.logger=INFO,console

 

 

5.3. Avro Sink

5.3.1. Avro Sink概述

Avro Sink是實現多級流動、扇出流(1到多) 和 扇入流(多到1) 的基礎。

5.3.2. Avro Sink屬性說明

!channel   –  

!type  –   Thecomponent type name, needs to be avro.

!hostname  –   Thehostname or IP address to bind to.

!port  –   Theport # to listen on.

batch-size 100 number of event to batch together for send.

connect-timeout   20000  Amount of time (ms) toallow for the first (handshake) request.

request-timeout   20000  Amount of time (ms) toallow for requests after the first.

reset-connection-interval   none   Amountof time (s) before the connection to the next hop is reset. This will force theAvro Sink to reconnect to the next hop. This will allow the sink to connect tohosts behind a hardware load-balancer when news hosts are added without havingto restart the agent.

compression-type  none   This can be “none” or “deflate”. The compression-type must match thecompression-type of matching AvroSource

compression-level 6   The level of compression tocompress event. 0 = no compression and 1-9 is compression. The higher thenumber the more compression

ssl false  Set to true to enable SSL for this AvroSink.When configuring SSL, you can optionally set a “truststore”, “truststore-password”, “truststore-type”, and specify whether to “trust-all-certs”.

trust-all-certs   false  If this is set totrue, SSL server certificates for remote servers (Avro Sources) will not bechecked. This should NOT be used in production because it makes it easier foran attacker to execute a man-in-the-middle attack and “listen in” on the encrypted connection.

truststore –   Thepath to a custom Java truststore file. Flume uses the certificate authorityinformation in this file to determine whether the remote Avro Source’s SSL authentication credentials should betrusted. If not specified, the default Java JSSE certificate authority files(typically “jssecacerts” or “cacerts” in theOracle JRE) will be used.

truststore-password  –   The password for the specified truststore.

truststore-type   JKS The type of the Javatruststore. This can be “JKS” or othersupported Java truststore type.

exclude-protocols SSLv3  Space-separated list ofSSL/TLS protocols to exclude. SSLv3 will always be excluded in addition to theprotocols specified.

maxIoWorkers  2 * the number of available processors in the machine   The maximum number of I/O w

5.3.3. 案例1-多級流動

我們用兩臺機器h1、h2來進行實驗:

h2:

    配置配置文件:

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=avro

       a1.sources.r1.bind=0.0.0.0

       a1.sources.r1.port=9988

 

       #描述Sink

       a1.sinks.k1.type=logger

      

#描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

 

    啓動flume:

./flume-ng agent--conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

 

             

h1:

    配置配置文件

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=http

       a1.sources.r1.port=8888

 

       #描述Sink

       a1.sinks.k1.type=avro

       a1.sinks.k1.hostname=192.168.242.138

       a1.sinks.k1.port=9988

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

    啓動flume:

./flume-ng agent--conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

 

發送http請求到h1:

    curl-X POST -d '[{ "headers" :{"a" :"a1","b" : "b1"},"body" :"hello~http~flume~"}]' http://192.168.242.133:8888

 

稍等幾秒後,發現h2最終收到了這條消息

 

 

5.3.4. 案例2-扇出流-複製

 

h2 h3:

    配置配置文件:

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=avro

       a1.sources.r1.bind=0.0.0.0

       a1.sources.r1.port=9988

 

       #描述Sink

       a1.sinks.k1.type=logger

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

 

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

 

h1:

    配置配置文件

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1k2

       a1.channels=c1c2

 

       #描述/配置Source

       a1.sources.r1.type=http

       a1.sources.r1.port=8888

 

       #描述Sink

       a1.sinks.k1.type=avro

       a1.sinks.k1.hostname=192.168.242.138

       a1.sinks.k1.port=9988

       a1.sinks.k2.type=avro

       a1.sinks.k2.hostname=192.168.242.135

       a1.sinks.k2.port=9988

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

       a1.channels.c2.type=memory

       a1.channels.c2.capacity=1000

       a1.channels.c2.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1c2

       a1.sinks.k1.channel=c1  

       a1.sinks.k2.channel=c2

   

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

5.3.5. 案例3-扇出流-多路複用(路由)

h2 h3:

    配置配置文件:

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=avro

       a1.sources.r1.bind=0.0.0.0

       a1.sources.r1.port=9988

 

       #描述Sink

       a1.sinks.k1.type=logger

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

 

h1:

    配置配置文件

       #配置Agent組件

       a1.sources=r1

       a1.sinks=k1k2

       a1.channels=c1c2

 

       #描述/配置Source

       a1.sources.r1.type=http

       a1.sources.r1.port=8888

       a1.sources.r1.selector.type=multiplexing

       a1.sources.r1.selector.header=flag

       a1.sources.r1.selector.mapping.aaa=c1

       a1.sources.r1.selector.mapping.bbb=c2

       a1.sources.r1.selector.default=c1

 

       #描述Sink

       a1.sinks.k1.type=avro

       a1.sinks.k1.hostname=192.168.242.138

       a1.sinks.k1.port=9988

       a1.sinks.k2.type=avro

       a1.sinks.k2.hostname=192.168.242.135

       a1.sinks.k2.port=9988

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

       a1.channels.c2.type=memory

       a1.channels.c2.capacity=1000

       a1.channels.c2.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1c2

       a1.sinks.k1.channel=c1

       a1.sinks.k2.channel=c2

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template8.conf --name a1-Dflume.root.logger=INFO,console

 

    發送http請求進行測試。發現可以實現路由效果

5.3.6. 案例4-扇入流

m3:

    編寫配置文件:

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=avro

       a1.sources.r1.bind=0.0.0.0

       a1.sources.r1.port=4141

 

       #描述Sink

       a1.sinks.k1.type=logger

 

       #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

 

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template.conf --name a1-Dflume.root.logger=INFO,console

          

m1、m2:

    編寫配置文件:

       #命名Agent組件

       a1.sources=r1

       a1.sinks=k1

       a1.channels=c1

 

       #描述/配置Source

       a1.sources.r1.type=http

       a1.sources.r1.port=8888

       #描述Sink

       a1.sinks.k1.type=avro

       a1.sinks.k1.hostname=192.168.242.135

       a1.sinks.k1.port=4141

             

    #描述內存Channel

       a1.channels.c1.type=memory

       a1.channels.c1.capacity=1000

       a1.channels.c1.transactionCapacity=1000

       #爲Channel綁定Source和Sink

       a1.sources.r1.channels=c1

       a1.sinks.k1.channel=c1

    啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template9.conf --name a1-Dflume.root.logger=INFO,console

 

    m1通過curl發送一條http請求,由於默認使用的是jsonHandler,數據格式必須是指定的json格式:

       [root@localhostconf]# curl -X POST -d '[{ "headers" :{"flag" :"c"},"body" : "idoall.org_body"}]'http://0.0.0.0:8888

   

m2通過curl發送一條http請求,由於默認使用的是jsonHandler,數據格式必須是指定的json格式:

       [root@localhostconf]# curl -X POST -d '[{ "headers" :{"flag" :"c"},"body" : "idoall.org_body"}]'http://0.0.0.0:8888

             

發現m3均能正確收到消息

5.4. HDFS Sink

5.4.1. HDFS Sink概述

HDFS Sink將事件寫入到Hadoop分佈式文件系統HDFS中,目前支持創建文本文件和序列化文件。並且對這兩種格式都支持壓縮。這些文件可以按照指定的時間或數據量或事件的數量爲基礎進行分卷。

它還通過類似時間戳或機器屬性對數據進行 buckets/partitions 操作。     HDFS的目錄路徑可以包含將要由HDFS替換格式的轉移序列用以生成存儲事件的目錄/文件名。

使用HDFS Sink要求hadoop必須已經安裝好,以便Flume可以通過hadoop提供的jar包與HDFS進行通信。

注意,此版本hadoop必須支持sync()調用。

5.4.2. HDFS Sink屬性說明

!channel   –  

!type  –   類型名稱,必須是“HDFS”

!hdfs.path –   HDFS目錄路徑 (eg hdfs://namenode/flume/webdata/)

hdfs.filePrefix   FlumeData  Flume在目錄下創建文件的名稱前綴

hdfs.fileSuffix   –   追加到文件的名稱後綴 (eg .avro - 注: 日期時間不會自動添加)

hdfs.inUsePrefix  –   Flume正在處理的文件所加的前綴

hdfs.inUseSuffix  .tmp   Flume正在處理的文件所加的後綴

hdfs.rollInterval 30  Number of seconds to wait beforerolling current file (0 = never roll based on time interval)

hdfs.rollSize 1024   File size to triggerroll, in bytes (0: never roll based on file size)

hdfs.rollCount    10  Number of events writtento file before it rolled (0 = never roll based on number of events)

hdfs.idleTimeout  0   Timeout after whichinactive files get closed (0 = disable automatic closing of idle files)

hdfs.batchSize    100 number of events writtento file before it is flushed to HDFS

hdfs.codeC –   Compressioncodec. one of following : gzip, bzip2, lzo, lzop, snappy

hdfs.fileType SequenceFile  File format:currently SequenceFile, DataStream or CompressedStream (1)DataStream will notcompress output file and please don’t set codeC (2)CompressedStream requires set hdfs.codeC with anavailable codeC

hdfs.maxOpenFiles 5000   Allow only this numberof open files. If this number is exceeded, the oldest file is closed.

hdfs.minBlockReplicas    –   Specify minimum number ofreplicas per HDFS block. If not specified, it comes from the default Hadoopconfig in the classpath.

hdfs.writeFormat  –   Format for sequence file records. One of “Text” or “Writable” (the default).

hdfs.callTimeout  10000  Number of millisecondsallowed for HDFS operations, such as open, write, flush, close. This numbershould be increased if many HDFS timeout operations are occurring.

hdfs.threadsPoolSize 10  Number of threads per HDFSsink for HDFS IO ops (open, write, etc.)

hdfs.rollTimerPoolSize   1   Numberof threads per HDFS sink for scheduling timed file rolling

hdfs.kerberosPrincipal   –   Kerberos user principal foraccessing secure HDFS

hdfs.kerberosKeytab  –   Kerberos keytab for accessing secure HDFS

hdfs.proxyUser        

hdfs.round false  時間戳是否向下取整(如果是true,會影響所有基於時間的轉移序列,除了%T)

hdfs.roundValue   1   舍值的邊界值

hdfs.roundUnit    向下舍值的單位 -  second, minute , hour

hdfs.timeZone Local Time Name of the timezonethat should be used for resolving the directory path, e.g. America/Los_Angeles.

hdfs.useLocalTimeStamp   false  Usethe local time (instead of the timestamp from the event header) while replacingthe escape sequences.

hdfs.closeTries   0   Number of times the sinkmust try renaming a file, after initiating a close attempt. If set to 1, thissink will not re-try a failed rename (due to, for example, NameNode or DataNodefailure), and may leave the file in an open state with a .tmp extension. If setto 0, the sink will try to rename the file until the file is eventually renamed(there is no limit on the number of times it would try). The file may stillremain open if the close call fails but the data will be intact and in thiscase, the file will be closed only after a Flume restart.

hdfs.retryInterval   180 Time in seconds betweenconsecutive attempts to close a file. Each close call costs multiple RPCround-trips to the Namenode, so setting this too low can cause a lot of load onthe name node. If set to 0 or less, the sink will not attempt to close the fileif the first attempt fails, and may leave the file open or with a ”.tmp” extension.

serializer TEXT   Other possible options include avro_event orthe fully-qualified class name of an implementation of theEventSerializer.Builder interface.

5.4.3. 案例

編寫配置文件:

    #命名Agent組件

    a1.sources=r1

    a1.sinks=k1

    a1.channels=c1

 

    #描述/配置Source

    a1.sources.r1.type=http

    a1.sources.r1.port=8888

   

#描述Sink

    a1.sinks.k1.type=hdfs

    a1.sinks.k1.hdfs.path=hdfs://0.0.0.0:9000/ppp

 

    #描述內存Channel

    a1.channels.c1.type=memory

    a1.channels.c1.capacity=1000

    a1.channels.c1.transactionCapacity=1000

 

    #爲Channel綁定Source和Sink

    a1.sources.r1.channels=c1

    a1.sinks.k1.channel=c1

 

啓動flume:

    ./flume-ngagent --conf ../conf --conf-file ../conf/template9.conf --name a1-Dflume.root.logger=INFO,console

5.5. Hive Sink

5.5.1. Hive Sink概述

這個Sink可以將含分隔符的文本或JSON數據事件直接導入Hive的表或分區。

事件Event是使用Hive transactions編寫的,當一組Event被提交到Hive中,他們立即可以通過Hive被查詢出來。

Flume要寫入數據的分區即可以預先創建好,也可以在缺失時由Flume來創建。

Flume收到的數據字段將映射到Hive表的列上。

此功能是一個預覽功能,不推薦在生產環境下使用。

5.5.2. Hive Sink屬性說明

!channel  –  

!type –   類型,必須設置爲“hive”

!hive.metastore  –   Hive metastore URI (egthrift://a.b.com:9083 )

!hive.database   –   hive庫名稱

!hive.table  –   hive表名稱

hive.partition    –   逗號分開的分區值確定寫入分區的列表。可以包含轉義序列。

hive.txnsPerBatchAsk 100 Hive grants a batch oftransactions instead of single transactions to streaming clients like Flume.This setting configures the number of desired transactions per TransactionBatch. Data from all transactions in a single batch end up in a single file.Flume will write a maximum of batchSize events in each transaction in thebatch. This setting in conjunction with batchSize provides control over thesize of each file. Note that eventually Hive will transparently compact these filesinto larger files.

heartBeatInterval 240 (In seconds) Intervalbetween consecutive heartbeats sent to Hive to keep unused transactions fromexpiring. Set this value to 0 to disable heartbeats.

autoCreatePartitions true   Flume will automaticallycreate the necessary Hive partitions to stream to

batchSize  15000  Max number of events written to Hive in asingle Hive transaction

maxOpenConnections   500 Allow only this number ofopen connections. If this number is exceeded, the least recently usedconnection is closed.

callTimeout   10000  (In milliseconds) Timeout for Hive & HDFSI/O operations, such as openTxn, write, commit, abort.

serializer    Serializer is responsible for parsingout field from the event and mapping them to columns in the hive table. Choiceof serializer depends upon the format of the data in the event. Supportedserializers: DELIMITED and JSON

roundUnit  minute The unit of the round down value - second,minute or hour.

roundValue 1   Rounded down to the highest multiple of this(in the unit configured using hive.roundUnit), less than current time

timeZone   LocalTime Name of the timezone that should beused for resolving the escape sequences in partition, e.g. America/Los_Angeles.

useLocalTimeStamp false  Use the local time(instead of the timestamp from the event header) while replacing the escapesequences.

5.6. Custom Sink

5.6.1. Custom Sink概述

自定義接收器,是自己實現的接收器接口Sink來實現的。

自定義接收器的類及其依賴類須在Flume啓動前放置到Flume類加載目錄下。

5.6.2. Custom Sink屬性說明

type   –   類型,需要指定爲自己實現的Sink類的全路徑名。

6.     Selector

6.1. Selector概述

Selector(選擇器)可以工作在複製或多路複用(路由) 模式下   。

 

6.2. 複製模式

6.2.1. Selector複製模式-屬性說明

selector.type replicating 類型名稱,必須是 replicating

selector.optional –   標誌通道爲可選

6.2.2. Selector複製模式-案例

           參看5.3.4avro sink案例.

6.3. 多路複用(路由)模式

 

6.3.1. Selector多路複用(路由)模式-屬性說明

selector.type 類型,必須是"multiplexing"

selector.header   指定要監測的頭的名稱   

selector.default  –  

selector.mapping.*   –

 

舉例:

    a1.sources= r1

    a1.channels= c1 c2 c3 c4

    a1.sources.r1.selector.type= multiplexing

    a1.sources.r1.selector.header= state

    a1.sources.r1.selector.mapping.CZ= c1

    a1.sources.r1.selector.mapping.US= c2 c3

    a1.sources.r1.selector.default= c4

6.3.2. Selector多路複用(路由)模式-案例

參看 5.3.5 avrosink案例

 

7.     Processor

7.1. Processor概述

Sink Group允許用戶將多個Sink組合成一個實體。

Flume Sink Processor 可以通過切換組內Sink用來實現負載均衡的效果,或在一個Sink故障時切換到另一個Sink。

7.2. Default Sink Processor

7.2.1. Default Sink Processor概述

Default Sink Processor 只接受一個 Sink,不要求用戶爲單一Sink創建processor.

7.2.2. Default Sink Processor屬性說明

sinks  –   用空格分隔的Sink集合

processor.type    default    類型名稱,必須是 default、failover 或 load_balance

 

7.3. Failover Sink Processor

7.3.1. Failover Sink Processor概述

Failover Sink Processor 維護一個sink們的優先表。確保只要一個是可用的就事件就可以被處理。

失敗處理原理爲:爲失效的sink指定一個冷卻時間,在冷卻時間到達後再重新使用。

sink們可以被配置一個優先級,數字越大優先級越高,如果sink發送事件失敗,則下一個最高優先級的sink將會嘗試接着發送事件;如果沒有指定優先級,則優先級順序取決於sink們的配置順序,先配置的默認優先級高於後配置的。

在配置的過程中,設置一個groupprocessor ,並且爲每個sink都指定一個優先級。優先級必須是唯一的。另外可以設置maxpenalty屬性指定限定失敗時間。

7.3.2. Failover Sink Processor屬性說明

sinks  –   用空格分隔的Sink集合

processor.type    默認類型名稱, needsto be failover

processor.priority.<sinkName>   –   Priority value.<sinkName> must be one of the sink instances associated with the currentsink group A higher priority value Sink gets activated earlier. A largerabsolute value indicates higher priority

processor.maxpenalty 30000  指定限定失敗時間指定限定失敗時間

7.3.3. Failover Sink Processor案例

------

    a1.sinkgroups = g1

    a1.sinkgroups.g1.sinks = k1k2

    a1.sinkgroups.g1.processor.type= failover

    a1.sinkgroups.g1.processor.priority.k1= 5

    a1.sinkgroups.g1.processor.priority.k2= 10

    a1.sinkgroups.g1.processor.maxpenalty= 10000

    ------

7.4. Load balancing Sink Processor

7.4.1. Load balancing Sink Processor概述

Load balancing Sink processor 提供了在多個sink之間實現負載均衡的能力,它維護了一個活動sink的索引列表,並支持輪詢或隨機方式的負載均衡,默認值是輪詢方式,可以通過配置指定,也可以通過實現AbstractSinkSelector接口實現自定義的選擇機制。

 

7.4.2. Load balancing Sink Processor屬性說明

!processor.sinks  –   Space-separated list of sinks that areparticipating in the group

!processor.type   default    The component typename, needs to be load_balance

processor.backoff false  Should failed sinks bebacked off exponentially.

processor.selector   round_robin   Selectionmechanism. Must be either round_robin, random or FQCN of custom class thatinherits from AbstractSinkSelector

processor.selector.maxTimeOut   30000  Usedby backoff selectors to limit exponential backoff (in milliseconds)

 

7.4.3. Load balancing Sink Processor案例

------

    a1.sinkgroups = g1

    a1.sinkgroups.g1.sinks = k1k2

a1.sinkgroups.g1.processor.type = load_balance

    a1.sinkgroups.g1.processor.backoff= true

    a1.sinkgroups.g1.processor.selector= random

------

 

 

8.     Interceptors

8.1. Interceptors概述

Flume有能力在運行階段修改/刪除Event,這是通過攔截器(Interceptors)來實現的。

攔截器需要實現org.apache.flume.interceptor.Interceptor接口。

攔截器可以修改或刪除事件基於開發者在選擇器中選擇的任何條件。

攔截器採用了責任鏈模式,多個攔截器可以按指定順序攔截。

一個攔截器返回的事件列表被傳遞給鏈中的下一個攔截器。

如果一個攔截器需要刪除事件,它只需要在返回的事件集中不包含要刪除的事件即可。

如果要刪除所有事件,只需返回一個空列表。

8.2. Timestamp Interceptor

8.2.1. Timestamp Interceptor概述

這個攔截器在事件頭中插入以毫秒爲單位的當前處理時間。

頭的名字爲timestamp,值爲當前處理的時間戳。

如果在之前已經有這個時間戳,則保留原有的時間戳。

8.2.2. Timestamp Interceptor屬性說明

!type  –   類型名稱,必須是timestamp或自定義類的全路徑名

preserveExisting  false  如果時間戳已經存在是否保留

 

8.3.  Host Interceptor

8.3.1. Host Interceptor概述

這個攔截器插入當前處理Agent的主機名或ip

頭的名字爲host或配置的名稱

值是主機名或ip地址,基於配置。

8.3.2. Host Interceptor屬性說明

!type  –   類型名稱,必須是host

preserveExisting  false  如果主機名已經存在是否保留

useIP  true   如果配置爲true則用IP,配置爲false則用主機名

hostHeader host   加入頭時使用的名稱

 

 

8.4.  Static Interceptor

8.4.1. Static Interceptor概述

此攔截器允許用戶增加靜態頭信息使用靜態的值到所有事件。

目前的實現中不允許一次指定多個頭。

如果需要增加多個靜態頭可以指定多個Static interceptors

8.4.2. Static Interceptor屬性說明

!type  –   類型,必須是static

preserveExisting  true   如果配置頭已經存在是否應該保留

key key 要增加的透明

value  value  要增加的頭值

8.5. UUID Interceptor

8.5.1. UUID Interceptor概述

這個攔截器在所有事件頭中增加一個全局一致性標誌,其實就是UUID。

8.5.2. UUID Interceptor屬性說明

!type  –   類型名稱,必須是org.apache.flume.sink.solr.morphline.UUIDInterceptor$Builder

headerName id  頭名稱

preserveExisting  true   如果頭已經存在,是否保留

prefix “”    在UUID前拼接的字符串前綴

 

8.6. Search and Replace Interceptor

8.6.1. Search and Replace Interceptor概述

這個攔截器提供了簡單的基於字符串的正則搜索和替換功能。

8.6.2. Search and Replace Interceptor屬性說明

type   –   類型名稱,必須是"search_replace"

searchPattern –   要搜索和替換的正則表達式

replaceString –   要替換爲的字符串

charset    UTF-8  字符集編碼,默認utf-8

8.7. Regex Filtering Interceptor

8.7.1. Regex Filtering Interceptor概述

此攔截器通過解析事件體去匹配給定正則表達式來篩選事件,所提供的正則表達式即可以用來包含或刨除事件。

 

8.7.2. Regex Filtering Interceptor屬性說明

!type  –   類型,必須設定爲regex_filter

regex  ”.*” 所要匹配的正則表達式

excludeEvents false  如果是true則刨除匹配的事件,false則包含匹配的事件。

8.8. Regex Extractor Interceptor

8.8.1. Regex Extractor Interceptor概述

使用指定正則表達式匹配事件,並將匹配到的組作爲頭加入到事件中,它也支持插件化的序列化器用來格式化匹配到的組在加入他們作爲頭之前。

8.8.2. Regex Extractor Interceptor屬性說明

!type  –   類型,必須是regex_extractor

!regex –   要匹配的正則表達式

!serializers  –   Space-separated list of serializers formapping matches to header names and serializing their values. (See examplebelow) Flume provides built-in support for the following serializers:org.apache.flume.interceptor.RegexExtractorInterceptorPassThroughSerializerorg.apache.flume.interceptor.RegexExtractorInterceptorMillisSerializer

serializers.<s1>.type    default    Mustbe default(org.apache.flume.interceptor.RegexExtractorInterceptorPassThroughSerializer),org.apache.flume.interceptor.RegexExtractorInterceptorMillisSerializer, or theFQCN of a custom class that implementsorg.apache.flume.interceptor.RegexExtractorInterceptorSerializer

serializers.<s1>.name    –  

serializers.* –   Serializer-specific properties

9.     Channel

9.1. Memory Channel

9.1.1. Memory Channel概述

Memory Channel,內存通道;事件將被存儲在內存中的具有指定大小的隊列中。

非常適合那些需要高吞吐量但是失敗時會丟失數據的場景下。

9.1.2. Memory Channel屬性說明

!type  –   類型,必須是“memory”

capacity   100 事件存儲在信道中的最大數量

transactionCapacity  100 每個事務中的最大事件數

keep-alive 3   添加或刪除操作的超時時間

byteCapacityBufferPercentage    20  Definesthe percent of buffer between byteCapacity and the estimated total size of all eventsin the channel, to account for data in headers. See below.

byteCapacity  see description   Maximumtotal bytes of memory allowed as a sum of all events in this channel. Theimplementation only counts the Event body, which is the reason for providing thebyteCapacityBufferPercentage configuration parameter as well. Defaults to acomputed 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 havemultiple memory channels on a single JVM, and they happen to hold the samephysical events (i.e. if you are using a replicating channel selector from asingle source) then those event sizes may be double-counted for channelbyteCapacity purposes. Setting this value to 0 will cause this value to fallback to a hard internal limit of about 200 GB.

9.1.3. 案例

參見入門案例。

 

9.2. JDBC Channel

9.2.1. JDBC Channel概述

事件被持久存儲在可靠的數據庫中。目前支持嵌入式的Derby數據庫。如果可恢復性非常的重要可以使用這種方式。

9.3. File Channel

9.3.1. File Channel概述

性能會比較低下,但是即使程序出錯數據不會丟失

9.3.2. 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 backedup to. This directory must not be the same as the data directories or thecheckpoint directory

dataDirs   ~/.flume/file-channel/data  逗號分隔的目錄列表,用以存放日誌文件。使用單獨的磁盤上的多個目錄可以提高文件通道效率。

transactionCapacity  10000  The maximum size oftransaction supported by the channel

checkpointInterval   30000  Amount of time (inmillis) between checkpoints

maxFileSize   2146435071 一個日誌文件的最大尺寸

minimumRequiredSpace 524288000  Minimum Requiredfree space (in bytes). To avoid data corruption, File Channel stops acceptingtake/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 putoperation

use-log-replay-v1 false  Expert: Use old replaylogic

use-fast-replay   false  Expert: Replay withoutusing queue

checkpointOnClose true   Controls if a checkpointis created when the channel is closed. Creating a checkpoint on close speeds upsubsequent 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, supportedtypes: JCEKSFILE

encryption.keyProvider.keyStoreFile    –   Path to the keystore file

encrpytion.keyProvider.keyStorePasswordFile   –   Path to the keystorepassword file

encryption.keyProvider.keys –  List of all keys (e.g.history of the activeKey setting)

encyption.keyProvider.keys.*.passwordFile –   Path to the optional keypassword file

9.4. Spillable Memory Channel

9.4.1. Spillable Memory Channel概述

Spillable Memory Channel:內存溢出通道。

事件被存儲在內存隊列和磁盤中,內存隊列作爲主存儲,而磁盤作爲溢出內容的存儲。

內存存儲通過embeddedFile channel來進行管理,當內存隊列已滿時,後續的事件將被存儲在文件通道中,這個通道適用於正常操作期間適用內存通道已期實現高效吞吐,而在高峯期間適用文件通道實現高耐受性。通過降低吞吐效率提高系統可耐受性。

如果Agent崩潰,則只有存儲在文件系統中的事件可以被恢復;此通道處於試驗階段,不建議在生產環境中使用。

9.4.2. Spillable Memory Channel屬性說明

!type  –   類型,必須是"SPILLABLEMEMORY"

memoryCapacity    10000  內存中存儲事件的最大值,如果想要禁用內存緩衝區將此值設置爲0。

overflowCapacity  100000000  可以存儲在磁盤中的事件數量最大值。設置爲0可以禁用磁盤存儲。

overflowTimeout   3   在內存填充磁盤溢出之前等待的秒數。

byteCapacityBufferPercentage    20  Definesthe percent of buffer between byteCapacity and the estimated total size of allevents in the channel, to account for data in headers. See below.

byteCapacity  see description   Maximumbytes of memory allowed as a sum of all events in the memory queue. Theimplementation only counts the Event body, which is the reason for providingthe byteCapacityBufferPercentage configuration parameter as well. Defaults to acomputed 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 multiplememory channels on a single JVM, and they happen to hold the same physicalevents (i.e. if you are using a replicating channel selector from a singlesource) then those event sizes may be double-counted for channel byteCapacitypurposes. Setting this value to 0 will cause this value to fall back to a hardinternal limit of about 200 GB.

avgEventSize  500 Estimated average size ofevents, 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 channelis managed by Spillable Memory Channel. Use ‘overflowCapacity’ to set the File channel’s capacity.

 

9.5. 自定義渠道

9.5.1. 自定義渠道概述

自定義渠道需要自己實現Channel接口。

自定義Channle類及其依賴類必須在Flume啓動前放置到類加載的目錄下。

9.5.2. 自定義渠道屬性說明

type - 自己實現的Channle類的全路徑名稱

 

發佈了25 篇原創文章 · 獲贊 5 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章