随笔 - 15  文章 - 0  评论 - 0  阅读 - 2371

Flume 入门案例

  1. 案例需求:使用 Flume 监听一个端口,收集该端口数据,并打印到控制台。
  2. 安装 netcat 工具
    sudo yum install -y nc

  3. 判断 44444 端口是否被占用
    sudo netstat -nlp | grep 44444

  4. 在 flume 目录下创建 job 文件夹并进入 job 文件夹。

    mkdir job

    cd job

  5. 在 job 文件夹下创建 Flume Agent 配置文件 flume-netcat-logger.conf。

    vim flume-netcat-logger.conf

  6. 在 flume-netcat-logger.conf 文件中添加如下内容。

    复制代码
    # Name the components on this agent
    a1.sources = r1
    a1.sinks = k1
    a1.channels = c1
    
    # Describe/configure the source
    a1.sources.r1.type = netcat
    a1.sources.r1.bind = localhost
    a1.sources.r1.port = 44444
    
    # 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
    复制代码

    先按下ESC键,按:键,输入wq,保存退出

  7. 先开启 flume 监听端口

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

    或者

    bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-netcat-logger.conf -Dflume.root.logger=INFO,console

    参数说明:

    --conf/-c:表示配置文件存储在 conf/目录
    --name/-n:表示给 agent 起名为 a1
    --conf-file/-f:flume 本次启动读取的配置文件是在 job 文件夹下的 flume-telnet.conf文件。
    -Dflume.root.logger=INFO,console :-D 表示 flume 运行时动态修改 flume.root.logger参数属性值,并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、error。
    想要了解更多知识可去官网查询,配置文件来源于官方手册 http://flume.apache.org/FlumeUserGuide.html 
  8. 需要再开一个终端,使用 netcat 工具向本机的 44444 端口发送内容
    nc localhost 44444

    发送hello,

    另一边接收消息

  9. 这样环境搭建测试完成

     

posted on   hz15968199950  阅读(56)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示