Flume_Flume常用配置4_taildir.source_memory.channel_hdfs.sink

以下配置基于版本 apache-flume-1.8.0-bin


我们假定已经对Flume有一定了解,并且对Flume 的各个组件有一定了解。

我们演示一个基本的 
source  为 taildir源
channel 为 memory
sink 为 hdfs 类型
的配置示例:


上一个配置中,我们对spooldir 源进行了简单的讲解,也提出了spooldir 中存在的问题,这一章我们对 1.8新推出的

taildir 进行下讲解,taildir 可以完美解决 spooldir 中存在的问题。


我们对 taildir 的原理进行下简单的介绍,

taildir 对一个目录进行监测,目录不支持 正则,等表达式,

会生成一个json文件,其中记录了每个文件的消费偏移量。

1. 宕机后,会从偏移量继续消费 ,所以一般不存在数据重复发送的问题。


但是该功能为 1.8 的实验性功能,目前只支持linux 环境,下面是示例配置

我们在解压好的目录下创建 2个子目录  my-conf, my-bin

my-conf 存放了 对 agent (source, sink, channel) 的配置

my-bin 存放了  agent 的启动脚本



my-conf



my-bin



配置文件

my-conf/flume-taildir-memory-hdfs.properties

# example.conf: A single-node Flume configuration

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

# Describe/configure the source
hdfs_agent.sources.r1.type = TAILDIR
hdfs_agent.sources.r1.filegroups = f1
hdfs_agent.sources.r1.filegroups.f1 = /tmp/logs/tailDir/.*\.log
hdfs_agent.sources.r1.positionFile = /tmp/logs/tailDir/.flume/taildir_position.json

# Describe the sink
hdfs_agent.sinks.k1.type = hdfs
hdfs_agent.sinks.k1.hdfs.path = hdfs://192.168.75.128:9000/test/flume/hdfs_filegroups_source/%Y-%m-%d/
hdfs_agent.sinks.k1.hdfs.rollInterval = 3600
hdfs_agent.sinks.k1.hdfs.rollSize = 1048576
hdfs_agent.sinks.k1.hdfs.rollCount = 20
hdfs_agent.sinks.k1.hdfs.filePrefix = log_%Y%m%d_%H
hdfs_agent.sinks.k1.hdfs.fileSuffix = .txt
hdfs_agent.sinks.k1.hdfs.fileType = DataStream
hdfs_agent.sinks.k1.hdfs.useLocalTimeStamp = true

# Use a channel which buffers events in memory
hdfs_agent.channels.c1.type = memory
hdfs_agent.channels.c1.capacity = 1000
hdfs_agent.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
hdfs_agent.sources.r1.channels = c1
hdfs_agent.sinks.k1.channel = c1



执行脚本

my-bin/start_taildir_memory_hdfs.sh

#!/bin/bash

ROOT_PATH=$(dirname $(dirname $(readlink -f $0)))
cd $ROOT_PATH

bin/flume-ng agent --conf ./conf/ -f my-conf/flume-taildir-memory-hdfs.properties -Dflume.root.logger=INFO,console -n hdfs_agent




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值