Flume (八) Sources

Avro Source

监听Avro端口并从外部Avro客户端流接收事件。 当与另一个(previous hop)Flume代理上的内置Avro Sink配对时,它可以创建分层集合拓扑。 必需属性以粗体显示。

属性名称默认值描述
channels
type组件类型名称,需要是avro
bindhostname or IP address to listen on
portPort # to bind to
threads生成的最大工作线程数
selector.type
selector.*
interceptors以空格分隔的拦截器列表
interceptors.*
compression-typenoneThis can be “none” or “deflate”. The compression-type must match the compression-type of matching AvroSource
sslfalse将其设置为true以启用SSL加密。 您还必须指定“keystore”和“keystore-password”。
keystoreThis is the path to a Java keystore file. Required for SSL.
keystore-passwordThe password for the Java keystore. Required for SSL.
keystore-typeJKSThe type of the Java keystore. This can be “JKS” or “PKCS12”.
exclude-protocolsSSLv3要排除的SSL/TLS协议列表,以空格分隔。 除指定的协议外,将始终排除SSLv3。
ipFilterfalse将此设置为true以启用netty的ipFiltering
ipFilterRulesDefine 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
bindhostname or IP address to listen on
portPort # to bind to
threads生成的最大工作线程数
selector.type
selector.*
interceptors以空格分隔的拦截器列表
interceptors.*
compression-typenoneThis can be “none” or “deflate”. The compression-type must match the compression-type of matching AvroSource
sslfalse将其设置为true以启用SSL加密。 您还必须指定“keystore”和“keystore-password”。
keystoreThis is the path to a Java keystore file. Required for SSL.
keystore-passwordThe password for the Java keystore. Required for SSL.
keystore-typeJKSThe type of the Java keystore. This can be “JKS” or “PKCS12”.
exclude-protocolsSSLv3要排除的SSL/TLS协议列表,以空格分隔。 除指定的协议外,将始终排除SSLv3。
kerberosfalse设置为true以启用kerberos身份验证。 在kerberos模式下,成功进行身份验证需要agent-principal和agent-keytab。 安全模式下的Thrift源将仅接受已启用kerberos且已成功通过kerberos KDC验证的Thrift客户端的连接。
agent-principalThrift Source使用的kerberos主体对kerberos KDC进行身份验证。
agent-keytabThrift 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
commandThe command to execute
shell用于运行命令的shell调用。 例如 /bin/sh -c。 仅适用于依赖shell功能的命令,如通配符,后退标记,管道等。
restartThrottle10000尝试重新启动之前等待的时间(以毫秒为单位)
restartfalse是否应该重新执行已执行的cmd
logStdErrfalse是否应记录命令的stderr
batchSize20一次读取和发送到通道的最大行数
batchTimeout3000在向下游推送数据之前,如果未达到缓冲区大小,则等待的时间(以毫秒为单位)
selector.typereplicatingreplicating 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
initialContextFactoryInital Context Factory,例如:org.apache.activemq.jndi.ActiveMQInitialContextFactory
connectionFactory连接工厂应显示为的JNDI名称
providerURLJMS提供的URL
destinationNameDestination name
destinationTypeDestination type (queue or topic)
messageSelectorMessage selector to use when creating the consumer
userNameUsername for the destination/provider
passwordFileFile containing the password for the destination/provider
batchSize100Number of messages to consume in one batch
converter.typeDEFAULT用于将消息转换为flume事件的类。 见下文。
converter.*-Converter properties.
converter.charsetUTF-8仅限默认转换器。 将JMS文本消息转换为字节数组时使用的字符集。
createDurableSubscriptionfalse是否创建持久订阅。 持久订阅只能与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.typereplicating 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
port1499应该连接Scribe的端口
maxReadBufferBytes16384000Thrift Default FrameBuffer Size
workerThreads5Handing 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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值