Flume使用案例之实时读取本地文件到HDFS

楼高2年前技术文章708

Flume实时读取本地文件到HDFS

1.  创建flume-hdfs.conf文件

# 1 agent

a2.sources = r2

a2.sinks = k2

a2.channels = c2

 

# 2 source

a2.sources.r2.type = exec

a2.sources.r2.command = tail -F /opt/Andy

a2.sources.r2.shell = /bin/bash -c

 

# 3 sink

a2.sinks.k2.type = hdfs

a2.sinks.k2.hdfs.path = hdfs://dtstack_hdfs:9000/flume/%Y%m%d/%H

#上传文件的前缀

a2.sinks.k2.hdfs.filePrefix = logs-

#是否按照时间滚动文件夹

a2.sinks.k2.hdfs.round = true

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

a2.sinks.k2.hdfs.roundValue = 1

#重新定义时间单位

a2.sinks.k2.hdfs.roundUnit = hour

#是否使用本地时间戳

a2.sinks.k2.hdfs.useLocalTimeStamp = true

#积攒多少个EventflushHDFS一次

a2.sinks.k2.hdfs.batchSize = 1000

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

a2.sinks.k2.hdfs.fileType = DataStream

#多久生成一个新的文件

a2.sinks.k2.hdfs.rollInterval = 600

#设置每个文件的滚动大小

a2.sinks.k2.hdfs.rollSize = 134217700

#文件的滚动与Event数量无关

a2.sinks.k2.hdfs.rollCount = 0

#最小副本数

a2.sinks.k2.hdfs.minBlockReplicas = 1

 

# Use a channel which buffers events in memory

a2.channels.c2.type = memory

a2.channels.c2.capacity = 1000

a2.channels.c2.transactionCapacity = 100

 

# Bind the source and sink to the channel

a2.sources.r2.channels = c2

a2.sinks.k2.channel = c2

2. 执行监控配置

/opt/module/flume1.8.0/bin/flume-ng agent \

--conf /opt/module/flume1.8.0/conf/ \

--name a2 \

--conf-file /opt/module/flume1.8.0/jobconf/flume-hdfs.conf


相关文章

HBase Shell操作

基本操作1.进入HBase客户端命令行[root@cdh02 current]# hbase shell2.查看帮助命令hbase(main):001:0> help3.查看当前数据库中有哪些表...

Python 序列化与反序列化

1、为什么要序列化内存中的字典、列表、集合以及各种对象,如何保存到一个文件中?如果是自己定义的类的实例,如何保存到一个文件中?如何从文件中读取数据,并让它们在内存中再次恢复成自己对应的类的实例?要设计...

Python Web 自动化测试工具 — Selenium

Selenium 是一个 Web 自动化测试工具,Selenium 通过非常简洁方便的 API,使用 Selenium WebDrivers(Selenium web 驱动器)像使用 Firefox,...

Ranger-hdfs插件部署

Ranger-hdfs插件部署

部署在两个namenode节点解压插件cd /opt/hadooptar -xzvf ranger-2.4.0-hdfs-plugin.tar.gz -C /opt/cd /opt/ranger-2....

压测实操--TestDFSIO压测hdfs读写方案

压测实操--TestDFSIO压测hdfs读写方案

TestDFSIO主要是对hdfs的I/O性能进行测试,通过使用MapReduce作业来完成测试,作为并行读写文件进行I/O性能测试。每个map任务用于读或写每个文件,map的输出用于收集与处理文件相...

Apache hive 对接达梦数据库

Apache hive 对接达梦数据库

1、背景由于国产化需求,客户需要使用dm数据库作为hive的元数据库。需要进行对应适配2、配置本次使用的环境hive 3.1.3 hadoop 3.2.4 ranger 2.3.0 Spark ...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。