大数据全系列 教程
1869个小节阅读:466.9k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
案例2:监控指定路径,采集新增的文件,每10条记录写到一个文件中
具体步骤:
停止flume服务:Ctrl+C
复制配置文件
xxxxxxxxxx
[root@node3 ~]# cd /opt/flume-1.9.0/jobs/
[root@node3 jobs]# cp spooldir-hdfs1.conf spooldir-hdfs2.conf
修改文件spooldir-hdfs2.conf
xxxxxxxxxx
[root@node3 jobs]# vim spooldir-hdfs2.conf
# Describe the sink sink相关参数的配置
a1.sinks.k1.type = hdfs
# 指定在hdfs上的保持路径 时间会四舍五入
a1.sinks.k1.hdfs.path = /flume/events/%m-%d/%H%M
# 指定在hdfs上的文件前缀
a1.sinks.k1.hdfs.filePrefix = events-
# 设置目录的生成策略
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 1
a1.sinks.k1.hdfs.roundUnit = hour
# 配置文件的生成策略 10条event一个文件
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.rollSize = 0
a1.sinks.k1.hdfs.rollCount = 10
# 配置使用本地时间戳
a1.sinks.k1.hdfs.useLocalTimeStamp = true
# 为HDFS操作如open、write、flush、close准备的时间
a1.sinks.k1.hdfs.callTimeout = 60000
删除文件
xxxxxxxxxx
[root@node3 ~]# rm -f /root/log/*
启动flume
xxxxxxxxxx
[root@node3 jobs]# flume-ng agent --conf ./ --name a1 --conf-file spooldir-hdfs2.conf -Dflume.root.logger=INFO,console
拷贝文件到/root/log目录下
xxxxxxxxxx
[root@node3 ~]# cp nohup.out log/
[root@node3 ~]# cp anaconda-ks.cfg log/
[root@node3 ~]# cp passwd log/
查看hdfs文件系统
http://node1:9870/explorer.html#/flume/events
或
http://node2:9870/explorer.html#/flume/eventsa