大数据全系列 教程
1869个小节阅读:468.1k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
Exec source在启动时运行给定的Unix命令,并期望该进程继续在标准输出上生成数据。 如果进程出于任何原因退出,源也将退出,不会产生进一步的数据。 这意味着配置,如cat[命名管道]或tail-F[文件]将产生所需的结果。
参数如下:
Property Name | Default | Description |
---|---|---|
channels | – | |
type | – | The component type name, needs to be exec |
command | – | The command to execute |
shell | – | A shell invocation used to run the command. e.g. /bin/sh -c. Required only for commands relying on shell features like wildcards, back ticks, pipes etc. |
batchSize | 20 | The max number of lines to read and send to the channel at a time |
batchTimeout | 3000 | Amount of time (in milliseconds) to wait, if the buffer size was not reached, before data is pushed downstream |
具体操作步骤如下:
xxxxxxxxxx
[root@node3 flume-1.9.0]# cd jobs
[root@node3 jobs]# cp netcat-logger.conf exec-logger.conf
[root@node3 jobs]# vim exec-logger.conf
# Describe/configure the source source的配置
# 指定sources.r1类型
a1.sources.r1.type = exec
# 指定对应的命令
a1.sources.r1.command = tail -F /root/log.txt
# 指定解释上面命令的命令解释器是谁
a1.sources.r1.shell = /bin/bash -c
# 一批数据的数量:从Source到putList
a1.sources.r1.batchSize = 3
# 批的实效时间 单位为毫秒
a1.sources.r1.batchTimeout = 5000
启动flume
xxxxxxxxxx
[root@node3 jobs]# flume-ng agent --conf ./ --name a1 --conf-file exec-logger.conf -Dflume.root.logger=INFO,console
在node3的另外的一个连接窗口向/root/log.txt文件中不断添加文本,观察flume日志的变化
xxxxxxxxxx
echo 'itbaizhan1' >> log.txt
echo 'itbaizhan2' >> log.txt
echo 'itbaizhan3' >> log.txt
echo 'itbaizhan4' >> log.txt
echo 'itbaizhan5' >> log.txt
实时反馈
1. 关于Flume的Exec Source的描述,错误的是?注:a1代表agent的名称,r1代表source的名称,参数省略前面的"a1.sources.r1."
A type参数需指定为exec。
B command指定执行的哪个命令,比如 tail -F /root/log.txt。
C batchSize表示source在doPut向putList临时缓冲区中操作的一个批次数量。
D batchTimeout批次的超时时间,单位为秒。
答案:
1.D