设为首页 加入收藏

TOP

windows下flume配置与遇到的问题
2018-11-28 17:46:39 】 浏览:41
Tags:windows flume 配置 遇到 问题
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012762093/article/details/54943775

最近学习大数据,听到数据采集需要flume这一个东西。于是开始捣鼓环境,可能是linux上没有hadoop环境没成功。后来尝试了在windows环境下使用flume,虽然其中遇到种种问题,但总算解决了。

1、解压flume

2、在conf目录下新增a.conf

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = D:/work/logs/a #源日志文件位置

a1.sources.r1.deserializer = org.apache.flume.sink.solr.morphline.BlobDeserializer$Builder
a1.sources.r1.batchsize = 1


# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://132.122.237.125:9000/input/flume #需要放的hadoop input目标文件位置
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text


a1.sinks.k1.hdfs.batchSize = 1
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.rollcount = 1
a1.sinks.k1.hdfs.rollsize = 0
#a1.sinks.k1.hdfs.filePrefix = logFile.%Y-%m-%d  
a1.sinks.k1.hdfs.fileSuffix = .log #需要采集的数据后缀名
a1.sinks.k1.hdfs.useLocalTimeStamp = true
a1.sinks.k1.hdfs.idleTimeout = 60000


# 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
3、打开CMD,进入到flume bin目录下,输入命令:
flume-ng.cmd agent --conf ..\conf --conf-file ..\conf\a.conf --name a1
其中a.conf 就是自己写的配置文件

这就启动成功了


在指定的源文件地址D:/work/logs/a放入a.log文件,就能自动同步到HDFS上的flume文件夹内,同步后a.log文件名会改变,标识为已同步状态

但发现同步到flume的文件会有乱码问题,以下是解决方案:

a1.sinks.k1.hdfs.fileType = DataStream 
一开始配置文件写的是filetype,但配置文件识别大小写,改成 fileType之后就可以了。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇【Flume】flume文件监控的source.. 下一篇Flume内部原理

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目