美文网首页
尚硅谷大数据技术之Flume

尚硅谷大数据技术之Flume

作者: 尚硅谷教育 | 来源:发表于2018-12-04 14:30 被阅读20次

3.执行监控配置
[atguigu@hadoop102 flume]bin/flume-ng agent --conf conf/ --name a2 --conf-file job/flume-file-hdfs.conf 4.开启Hadoop和Hive并操作Hive产生日志 [atguigu@hadoop102 hadoop-2.7.2] sbin/start-dfs.sh
[atguigu@hadoop103 hadoop-2.7.2]$ sbin/start-yarn.sh

[atguigu@hadoop102 hive]bin/hive hive (default)> 5.在HDFS上查看文件。 ![image.png](https://img.haomeiwen.com/i10390889/4512ed3cafaf823e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 3.3 实时读取目录文件到HDFS案例 1)案例需求:使用Flume监听整个目录的文件 2)需求分析: ![image.png](https://img.haomeiwen.com/i10390889/d7e0ab54b655b2e0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 3)实现步骤: 1.创建配置文件flume-dir-hdfs.conf 创建一个文件 [atguigu@hadoop102 job] touch flume-dir-hdfs.conf
打开文件
[atguigu@hadoop102 job]$ vim flume-dir-hdfs.conf
添加如下内容
a3.sources = r3
a3.sinks = k3
a3.channels = c3

Describe/configure the source

a3.sources.r3.type = spooldir
a3.sources.r3.spoolDir = /opt/module/flume/upload
a3.sources.r3.fileSuffix = .COMPLETED
a3.sources.r3.fileHeader = true

忽略所有以.tmp结尾的文件,不上传

a3.sources.r3.ignorePattern = ([^ ]*.tmp)

Describe the sink

a3.sinks.k3.type = hdfs
a3.sinks.k3.hdfs.path = hdfs://hadoop102:9000/flume/upload/%Y%m%d/%H

上传文件的前缀

a3.sinks.k3.hdfs.filePrefix = upload-

是否按照时间滚动文件夹

a3.sinks.k3.hdfs.round = true

多少时间单位创建一个新的文件夹

a3.sinks.k3.hdfs.roundValue = 1

重新定义时间单位

a3.sinks.k3.hdfs.roundUnit = hour

是否使用本地时间戳

a3.sinks.k3.hdfs.useLocalTimeStamp = true

积攒多少个Event才flush到HDFS一次

a3.sinks.k3.hdfs.batchSize = 100

设置文件类型,可支持压缩

a3.sinks.k3.hdfs.fileType = DataStream

多久生成一个新的文件

a3.sinks.k3.hdfs.rollInterval = 600

设置每个文件的滚动大小大概是128M

a3.sinks.k3.hdfs.rollSize = 134217700

文件的滚动与Event数量无关

a3.sinks.k3.hdfs.rollCount = 0

最小冗余数

a3.sinks.k3.hdfs.minBlockReplicas = 1

Use a channel which buffers events in memory

a3.channels.c3.type = memory
a3.channels.c3.capacity = 1000
a3.channels.c3.transactionCapacity = 100

Bind the source and sink to the channel

a3.sources.r3.channels = c3
a3.sinks.k3.channel = c3

image.png

本教程由尚硅谷教育大数据研究院出品,如需转载请注明来源,欢迎大家关注尚硅谷公众号(atguigu)了解更多。

相关文章

网友评论

      本文标题:尚硅谷大数据技术之Flume

      本文链接:https://www.haomeiwen.com/subject/ahimcqtx.html