windows下flume配置与遇到的问题

最近学习大数据,听到数据采集需要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之后就可以了。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值