龙空技术网

玩过 Flume 吗,今天看了下入门教程,记录一些困惑和思考

毕小宝 137

前言:

当前看官们对“windows下的flume”大概比较关切,各位老铁们都想要了解一些“windows下的flume”的相关内容。那么小编同时在网摘上汇集了一些有关“windows下的flume””的相关知识,希望看官们能喜欢,你们快快来了解一下吧!

背景

Flume 日志采集框架,使用默认的组件简单运行了一下。

本文介绍 sink 使用 file_roll 的配置及疑惑。

windows 下命令语法

下载压缩文件后解压到本地,跟其他 Apache 项目一样,是一个二进制文件包,运行文件位于 bin 目录中,启动 agent 的语法如下:

flume-ng.cmd agent [OPTION]

OPTION 基础选项:

--conf 配置文件所在的目录--config-file agent 启动的配置文件--name 需要启动的 agent 名称配置一个 sink 为 file_role 的 demo

agent1.sinks.loggerSink.type = file_rollagent1.sinks.loggerSink.sink.directory = E:/file_rollagent1.sinks.loggerSink.sink.rollInterval = 0

这个配置项目,跟我理解的不太一样:

directory 属性之前多了一个 sink 前缀,我理解的 directory 和 type 一样是同一等级的属性,初看以为配置写错了呢。directory 指定的是文件目录,且必须创建,如果不存在,flume 不会自行创建,程序后台报异常,但是控制台不会输出异常。技术运用思考是否支持集群部署呢?多 Agnet 和多路复用流。sinkgroup 跟单个 sink 的区别是什么?为什么会有转发的需求呢?

官方有一个转发 flow 的配置案例:

To setup a multi-tier flow, you need to have an avro/thrift sink of first hop pointing to avro/thrift source of the next hop. This will result in the first Flume agent forwarding events to the next Flume agent. For example, if you are periodically sending files (1 file per event) using avro client to a local Flume agent, then this local agent can forward it to another agent that has the mounted for storage.

周期性的发送 webserver 的日志给本地 Flume Agent,然后再由它转发给下一个能够存储的 Agent。

为什么要多一层转发,而不是直接配置 sink 输出为下一跳的 HDFS 的输出呢?

我想到一种可能是网络不通时,可以通过这个配置,当做转发跳板,完成不连通网段的日志转发。

selector 的 optional 配置生效步骤

一个 source 可以转发 Event 到多个 Channel 中,Flume 提供了 selector 配置转发路由,根据官方文档,总结必须转发的 Channel 和可选转发的 Channel 以及默认转发的 Channel 生效的顺序。

第一个知识点, selector.type 有两个选项,replicatingmultiplexing ,默认是 replicating

第二个知识点,按官方示例对某个 source 的 selector 配置了必须、可选、默认的 Channel :

# channel selector configurationagent_foo.sources.avro-AppSrv-source1.selector.type = multiplexingagent_foo.sources.avro-AppSrv-source1.selector.header = Stateagent_foo.sources.avro-AppSrv-source1.selector.mapping.CA = mem-channel-1agent_foo.sources.avro-AppSrv-source1.selector.mapping.AZ = file-channel-2agent_foo.sources.avro-AppSrv-source1.selector.mapping.NY = mem-channel-1 file-channel-2agent_foo.sources.avro-AppSrv-source1.selector.optional.CA = mem-channel-1 file-channel-2agent_foo.sources.avro-AppSrv-source1.selector.mapping.AZ = file-channel-2agent_foo.sources.avro-AppSrv-source1.selector.default = mem-channel-1

转发 Event 的流程中,匹配 CA 的事件:

先尝试转发必须映射Channel mem-channel-1 中。如果第一步转发失败,则重试继续写入 mem-channel-1 。mem-channel-1 写入成功后,再尝试写入可选的 Channel file-channel-2,如果写入失败,则不会重试。optional 如果直接配置在全局事件上,此时没有匹配的 Event 会进入 default ,同时也会进入 optional 的 Channel 。SSL 参数配置

The SSL system properties can either be passed on the command line or by setting the JAVA_OPTS environment variable in conf/flume-env.sh. (Although, using the command line is inadvisable because the commands including the passwords will be saved to the command history.)

参数设置的方式有两种,一种是 Java 的环境变量,另一种是 Flume 的环境参数,官方不建议通过命令行的方式设置 Java 环境变量,因为命令会记入操作系统的 history 文件中,包含的 SSL 的敏感信息会暴露。

但问题时,SSL 参数配置中有明文,通过配置文件也还是有暴露的风险啊。

知识点 ,SSL 配置生效的优先级,从高到低:

组件级别的参数配置。Java 系统环境变量。Flume 的环境变量。

标签: #windows下的flume