Flume (八) Sources

Avro Source

監聽Avro端口並從外部Avro客戶端流接收事件。 當與另一個(previous hop)Flume代理上的內置Avro Sink配對時,它可以創建分層集合拓撲。 必需屬性以粗體顯示。

屬性名稱 默認值 描述
channels
type 組件類型名稱,需要是avro
bind hostname or IP address to listen on
port Port # to bind to
threads 生成的最大工作線程數
selector.type
selector.*
interceptors 以空格分隔的攔截器列表
interceptors.*
compression-type none This can be “none” or “deflate”. The compression-type must match the compression-type of matching AvroSource
ssl false 將其設置爲true以啓用SSL加密。 您還必須指定“keystore”和“keystore-password”。
keystore This is the path to a Java keystore file. Required for SSL.
keystore-password The password for the Java keystore. Required for SSL.
keystore-type JKS The type of the Java keystore. This can be “JKS” or “PKCS12”.
exclude-protocols SSLv3 要排除的SSL/TLS協議列表,以空格分隔。 除指定的協議外,將始終排除SSLv3。
ipFilter false 將此設置爲true以啓用netty的ipFiltering
ipFilterRules Define N netty ipFilter pattern rules with this config.

Example for agent named a1:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141

ipFilterRules的示例

ipFilterRules定義由逗號分隔的N個netty ipFilters模式規則必須採用此格式。

<’allow’ or deny>:<’ip’ or ‘name’ for computer name>:<pattern> or allow/deny:ip/name:pattern

example: ipFilterRules=allow:ip:127.*,allow:name:localhost,deny:ip:*

請注意,匹配的第一個規則將適用,如下面的示例所示,來自localhost上的客戶端

這將允許localhost上的客戶端拒絕來自任何其他ip的客戶端“allow:name:localhost,deny:ip:”這將拒絕localhost上的客戶端允許來自任何其他ip的客戶端“deny:name:localhost,allow:ip:“

Thrift Source

偵聽Thrift端口並從外部Thrift客戶端流接收事件。 當與另一個(previous hop)Flume代理上的內置ThriftSink配對時,它可以創建分層集合拓撲。 可以通過啓用kerberos身份驗證將Thrift源配置爲以安全模式啓動。 agent-principal和agent-keytab是Thrift源用於向kerberos KDC進行身份驗證的屬性。 必需屬性以粗體顯示。

屬性名稱 默認值 描述
channels
type 組件類型名稱,需要是avro
bind hostname or IP address to listen on
port Port # to bind to
threads 生成的最大工作線程數
selector.type
selector.*
interceptors 以空格分隔的攔截器列表
interceptors.*
compression-type none This can be “none” or “deflate”. The compression-type must match the compression-type of matching AvroSource
ssl false 將其設置爲true以啓用SSL加密。 您還必須指定“keystore”和“keystore-password”。
keystore This is the path to a Java keystore file. Required for SSL.
keystore-password The password for the Java keystore. Required for SSL.
keystore-type JKS The type of the Java keystore. This can be “JKS” or “PKCS12”.
exclude-protocols SSLv3 要排除的SSL/TLS協議列表,以空格分隔。 除指定的協議外,將始終排除SSLv3。
kerberos false 設置爲true以啓用kerberos身份驗證。 在kerberos模式下,成功進行身份驗證需要agent-principal和agent-keytab。 安全模式下的Thrift源將僅接受已啓用kerberos且已成功通過kerberos KDC驗證的Thrift客戶端的連接。
agent-principal Thrift Source使用的kerberos主體對kerberos KDC進行身份驗證。
agent-keytab Thrift Source與代理主體結合使用的keytab位置,用於對kerberos KDC進行身份驗證。

代理名爲a1的示例:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = thrift
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141

Exec Source

Exec源在啓動時運行給定的Unix命令,並期望該進程在標準輸出上連續生成數據(除非將屬性logStdErr設置爲true,否則將丟棄stderr)。 如果進程因任何原因退出,則源也會退出並且不會產生更多數據。 這意味着諸如cat [named pipe]或tail -F [file]之類的配置將產生所需的結果,而日期可能不會 - 前兩個命令產生數據流,而後者產生單個事件並退出。

必需屬性以粗體顯示。

屬性名稱 默認值 描述
channels
type 組件類型名稱,需要是avro
command The command to execute
shell 用於運行命令的shell調用。 例如 /bin/sh -c。 僅適用於依賴shell功能的命令,如通配符,後退標記,管道等。
restartThrottle 10000 嘗試重新啓動之前等待的時間(以毫秒爲單位)
restart false 是否應該重新執行已執行的cmd
logStdErr false 是否應記錄命令的stderr
batchSize 20 一次讀取和發送到通道的最大行數
batchTimeout 3000 在向下遊推送數據之前,如果未達到緩衝區大小,則等待的時間(以毫秒爲單位)
selector.type replicating replicating or multiplexing
selector.* 取決於selector.type值
interceptors 以空格分隔的攔截器列表
interceptors.*

警告:ExecSource和其他異步源的問題是如果在將事件放入channel中時出現錯誤,源無法保證客戶端是否知道。在這種情況下,數據將丟失。例如,最常請求的功能之一是tail -F [file]類似的用例,其中應用程序寫入磁盤上的日誌文件,Flume將文件尾部發送,將每一行作爲事件發送。雖然這是可能的,但是有一個明顯的問題;如果頻道填滿並且Flume無法發送事件,會發生什麼?由於某種原因,Flume無法向編寫日誌文件的應用程序指示它需要保留日誌或事件尚未發送。如果這沒有意義,您只需要知道:當使用ExecSource等單向異步接口時,您的應用程序永遠無法保證數據被接收!作爲此警告的延伸 - 並且完全清楚 - 使用此源時,事件傳遞絕對沒有保證。爲了獲得更強的可靠性保證,請考慮Spooling Directory Source,Taildir Source或通過SDK直接與Flume集成。

Example for agent named a1:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /var/log/secure
a1.sources.r1.channels = c1

shell配置用於通過shell命令(例如Bash或Powershell)調用commandcommand作爲參數傳遞給shell以便執行。 這允許command使用shell中的功能,例如通配符,後退標記,管道,循環,條件等。如果沒有shell配置,將直接調用commandshell的常用值:bin/sh -c/bin/ksh -ccmd/cpowershell -Command等。

a1.sources.tailsource-1.type = exec
a1.sources.tailsource-1.shell = /bin/bash -c
a1.sources.tailsource-1.command = for i in /path/*.txt; do cat $i; done

JMS Source

JMS Source從JMS目標(例如隊列或主題)讀取消息。 作爲JMS應用程序,它應該與任何JMS提供程序一起使用,但僅使用ActiveMQ進行測試。 JMS源提供可配置的批量大小,消息選擇器,用戶/傳遞和消息到flume事件轉換器。 請注意,供應商提供的JMS jar應該包含在Flume類路徑中,使用plugins.d目錄(首選),命令行上的-classpathflume-env.sh中的FLUME_CLASSPATH變量。

必需屬性以粗體顯示。

屬性名稱 默認值 描述
channels
type 組件類型名稱,需要是avro
initialContextFactory Inital Context Factory,例如:org.apache.activemq.jndi.ActiveMQInitialContextFactory
connectionFactory 連接工廠應顯示爲的JNDI名稱
providerURL JMS提供的URL
destinationName Destination name
destinationType Destination type (queue or topic)
messageSelector Message selector to use when creating the consumer
userName Username for the destination/provider
passwordFile File containing the password for the destination/provider
batchSize 100 Number of messages to consume in one batch
converter.type DEFAULT 用於將消息轉換爲flume事件的類。 見下文。
converter.* - Converter properties.
converter.charset UTF-8 僅限默認轉換器。 將JMS文本消息轉換爲字節數組時使用的字符集。
createDurableSubscription false 是否創建持久訂閱。 持久訂閱只能與destinationType主題一起使用。 如果爲true,則必須指定“clientId”和“durableSubscriptionName”。
clientId - JMS客戶端標識符在創建後立即在Connection上設置。 持久訂閱必需。
durableSubscriptionName - 用於標識持久訂閱的名稱。 持久訂閱必需。
Converter

JMS源允許可插拔轉換器,儘管默認轉換器可能適用於大多數用途。 默認轉換器能夠將Bytes,Text和Object消息轉換爲FlumeEvents。 在所有情況下,消息中的屬性都作爲標題添加到FlumeEvent中。

BytesMessage:消息的字節被複制到FlumeEvent的主體。 每封郵件無法轉換超過2GB的數據。
TextMessage的:消息文本轉換爲字節數組並複製到FlumeEvent的主體。 默認轉換器默認使用UTF-8,但這是可配置的。
ObjectMessage:將對象寫入包含在ObjectOutputStream中的ByteArrayOutputStream,並將生成的數組複製到FlumeEvent的主體。

Example for agent named a1:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = jms
a1.sources.r1.channels = c1
a1.sources.r1.initialContextFactory = org.apache.activemq.jndi.ActiveMQInitialContextFactory
a1.sources.r1.connectionFactory = GenericConnectionFactory
a1.sources.r1.providerURL = tcp://mqserver:61616
a1.sources.r1.destinationName = BUSINESS_DATA
a1.sources.r1.destinationType = QUEUE

Spooling Directory Source

Taildir Source

Twitter 1% firehose Source (experimental)

NetCat TCP Source

NetCat UDP Source

Sequence Generator Source

Syslog Sources

Syslog TCP Source
Multiport Syslog TCP Source
Syslog UDP Source

HTTP Source

Stress Source

Legacy Sources

Avro Legacy Source
Thrift Legacy Source

Custom Source

自定義source是您自己的Source接口實現。 啓動Flume代理時,自定義source的類及其依賴項必須包含在代理程序的類路徑中。 自定義源的類型是其FQCN。

屬性名稱 默認值 描述
channels
type 組件類型名稱,需要是FQCN
selector.type replicating or multiplexing
selector.* replicating 取決於selector.type值
interceptors 以空格分隔的攔截器列表
interceptors.*

Example for agent named a1:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = org.example.MySource
a1.sources.r1.channels = c1

Scribe Source

Scribe是另一種攝取系統。 要採用現有的Scribe攝取系統,Flume應該使用基於Thrift的ScribeSource和兼容的傳輸協議。 要部署Scribe,請遵循Facebook的指南。

屬性名稱 默認值 描述
type 組件類型名稱,需要是org.apache.flume.source.scribe.ScribeSource
port 1499 應該連接Scribe的端口
maxReadBufferBytes 16384000 Thrift Default FrameBuffer Size
workerThreads 5 Handing threads number in Thrift
selector.type
selector.*

Example for agent named a1:

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = org.apache.flume.source.scribe.ScribeSource
a1.sources.r1.port = 1463
a1.sources.r1.workerThreads = 5
a1.sources.r1.channels = c1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章