• 使用 Avro 数据源测试 Flume


    2. 使用 Avro 数据源测试 Flume
    Avro 可以发送一个给定的文件给 Flume,Avro 源使用 AVRO RPC 机制。请对 Flume
    的相关配置文件进行设置,从而可以实现如下功能:在一个终端中新建一个文件
    helloworld.txt(里面包含一行文本“Hello World”),在另外一个终端中启动 Flume 以后,
    可以把 helloworld.txt 中的文本内容显示出来。

    cd /usr/local/flume
    sudo vim ./conf/avro.conf

    添加如下:

    a1.sources = r1
    a1.sinks = k1
    a1.channels = c1
    
    # Describe/configure the source
    a1.sources.r1.type = avro
    a1.sources.r1.channels = c1
    a1.sources.r1.bind = 0.0.0.0
    a1.sources.r1.port = 4141
    
    # 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

    将helloworld.txt放在flume的主目录路径下。

     启动agent

    ./bin/flume-ng agent agent -c conf -f ./conf/avro.conf -n a1 -Dflume.root.logger=INFO,console

    在同目录下新建一个命令终端,使用avro-client发送文件

    ./bin/flume-ng avro-client -H localhost -p 4141 -F ./helloworld.txt

    这是就可以在第一个命令终端中看到输出的“hello world!”了

  • 相关阅读:
    Python连接MySQL数据库之pymysql模块使用
    前端基础之BOM和DOM
    前端基础之JavaScript
    前端基础之CSS
    前端知识之HTML内容
    Python基础—名称空间(Day10)
    Python基础—装饰器(Day11)
    Python基础—迭代器、生成器(Day13)
    Python基础—文件操作(Day8)
    Python基础—函数(Day9)
  • 原文地址:https://www.cnblogs.com/a155-/p/14294063.html
Copyright © 2020-2023  润新知