美文网首页
flume学习笔记

flume学习笔记

作者: DB_BOY | 来源:发表于2019-04-09 16:00 被阅读0次

0. 安装

  1. 下载

wget http://apache.fayea.com/flume/1.7.0/apache-flume-1.7.0-bin.tar.gz

  1. 解压

tar -zxvf apache-flume-1.7.0-bin.tar.gz

  1. 环境变量

    • 建立符号连接 ln -s xxx /soft/flume
    • 配置/etc/profile
  2. 启动

flume-ng agent -f /soft/flume/conf/nc2kafka.conf -n a1 -Dflume.root.logger=INFO,console

1. 自定义Interceptor

LogInterceptor

2. 配置文件

详细官方文档

0. netcat 2 logger

# -----nc2log.conf
#netcat 2 logger
a1.sources = r1
a1.sinks = k1
a1.channels = c1

#netcat 8888 端口
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 8888

# Describe the sink
a1.sinks.k1.type = logger

# 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

1. netcat 2 kafka

# -----nc2kafka.conf
#netcat 2 kafka
a1.sources = r1
a1.sinks = k1
a1.channels = c1

#netcat 8888 端口
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 8888

a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = hellokfk
a1.sinks.k1.kafka.bootstrap.servers = localhost:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1

a1.channels.c1.type = memory

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

2. spool 2 logger

# -----sp2log.conf
#spool 2 logger

a1.sources = r1
a1.channels = c1
a1.sinks = k1

#source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /soft/log
a1.sources.r1.consumeOrder = youngest
a1.sources.r1.recursiveDirectorySearch = false
a1.sources.r1.deletePolicy = immediate
a1.sources.r1.pollDelay = 500

#自定义flume interceptor
#如果不需要可以去掉
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = cn.dbboy.flume.LogInterceptor$Builder
a1.sources.r1.interceptors.i1.pattern = before:after

#channe1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

#sink
a1.sinks.k1.type = logger

#package
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3. spool 2 kafka

# -----sp2kafka.conf
#spool 2 logger
#agent
a1.sources = r1
a1.channels = c1
a1.sinks = k1

#source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /soft/log
a1.sources.r1.consumeOrder = youngest
a1.sources.r1.recursiveDirectorySearch = false
a1.sources.r1.deletePolicy = immediate
a1.sources.r1.pollDelay = 500

#自定义flume interceptor
#如果不需要可以去掉
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = cn.dbboy.flume.LogInterceptor$Builder
a1.sources.r1.interceptors.i1.pattern = before:after


#channe1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

#sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = hellokfk
a1.sinks.k1.kafka.bootstrap.servers = localhost:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1


#package
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

相关文章

  • Flume学习笔记

    官方文档 核心组件 Source 收集 Channel 聚集 Sink 输出 Flume 安装前置条件 Java ...

  • Flume学习笔记

    本文是对大数据组件Flume的一个学习总结,共包括如下章节的内容: 简介 核心概念 使用场景 快速起步 小结 一、...

  • flume学习笔记

    0. 安装 下载 wget http://apache.fayea.com/flume/1.7.0/apache-...

  • Hadoop学习笔记(3)-Flume

    自行整理, 学习用途, 侵知删歉Flume的设计目标: 可靠性, 可量测性, 可扩展性 Agent将数据写成多种H...

  • 大数据开发学习笔记——flume集成hive

    又是周五啦~ 分享完就回家过周末~_~ flume集成hive的笔记 1、 确定你的flume在哪台主机上 2、 ...

  • flume笔记

    最近要准备做一个系统监控小项目,简要分析了需求之后决定用当下比较火的flume-kafka-spark-sprin...

  • flume笔记

    flume 安装后基本的测试验证: 配置 source 使用 necat 类型,sink 采用 file_roll...

  • flume笔记

    Flume是一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统。 一、主要组件: 二、flume使用案例

  • Flume学习

    1. Flume架构 https://blog.csdn.net/a2011480169/article/deta...

  • flume学习与总结记录

    1.什么是flume Cloudera 开发的框架,实时收集数据 Flume学习的核心: agent的设计 官方文...

网友评论

      本文标题:flume学习笔记

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