既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
3、exec 源
- exec源在启动时运行给定的unix命令,并期望该进程在标准输出上不断生成数据(stderr被简单丢弃,除非属性logStdErr设置为true)。如果进程因任何原因退出,源也会退出,并且不会产生进一步的数据。
- 这意味着配置例如
cat [named pipe] or tail -F [file]
将产生预期的结果日期可能不会-前两个命令生成数据流,后者生成单个事件并退出。
利用exec源监控某个文件
利用node2上的 flume 进行配置
官方介绍如下
- 编写自定义配置文件 option-exec
[root@node2 dirflume]# vim option-exec
# 配置文件内容
# 主要是通过 a1.sources.r1.command = tail -F /root/log.txt 这条配置来监控log.txt文件中的内容
# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /root/log.txt
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
- 创建被监控的文件( 文件没有会自动创建, 但是下面演示目录不会)
vim /root/log.txt
# 文件内容如下
hello flume
- 启动 flume ,查看结果( 图1)
flume-ng agent --conf-file option-exec --name a1 -Dflume.root.logger=INFO,console
- 我们可以通过echo 向文件中追加内容 ,查看node2的 flume的阻塞式界面是否显示数据(图2,图3)
echo 'hello flume' >> /root/log.txt
echo 'hello flume' >> /root/log.txt
echo 'hello flume' >> /root/log.txt
....
注意 :
a.我们通常在项目中使用exec源来监控某些日志文件的数据
b.我们可以通过修改配置文件中的a1.sources.r1.command = tail -F /root/log.txt配置来决定是否在一开始读取时读取全部文件,如果我们使用的是 tail -f -n 3 /root/log.txt 则是从倒数第三行开始输出
图1
图2
图3