• flume安装


    Flume安装

    下载flume,解压到指定目录

    tar -zxf apache-flume-1.9.0-bin.tar.gz -C /opt/software/

     

    在flume的conf文件夹下新建log-kafka.properties

    内容为:

    agent.sources = exectail

    agent.channels = memoryChannel

    agent.sinks = kafkasink

    # For each one of the sources, the type is defined

    agent.sources.exectail.type = exec

    # 下面这个路径是需要收集日志的绝对路径,改为自己的日志目录

    agent.sources.exectail.command = tail -f /home/hadoop/flume/log/agent.log

    agent.sources.exectail.interceptors=i1

    agent.sources.exectail.interceptors.i1.type=regex_filter

    # 定义日志过滤前缀的正则

    agent.sources.exectail.interceptors.i1.regex=.+PRODUCT_RATING_PREFIX.+

    # The channel can be defined as follows.

    agent.sources.exectail.channels = memoryChannel

    # Each sink's type must be defined

    agent.sinks.kafkasink.type = org.apache.flume.sink.kafka.KafkaSink

    agent.sinks.kafkasink.kafka.topic = log

    agent.sinks.kafkasink.kafka.bootstrap.servers = localhost:9092

    agent.sinks.kafkasink.kafka.producer.acks = 1

    agent.sinks.kafkasink.kafka.flumeBatchSize = 20

    #Specify the channel the sink should use

    agent.sinks.kafkasink.channel = memoryChannel

    # Each channel's type is defined.

    agent.channels.memoryChannel.type = memory

    # Other config values specific to each type of channel(sink or source)

    # can be defined as well

    # In this case, it specifies the capacity of the memory channel

    agent.channels.memoryChannel.capacity = 10000

    上述配置文件功能描述:

    使用tail -f /home/hadoop/flume/log/agent.log命令,监听文件中改动的内容,通过正则表达式.+PRODUCT_RATING_PREFIX.+匹配内容,将匹配的结果发送到localhost:9092中Kafka的log主题中

    进入flume目录,执行启动命令:

    cd ~/flume

    ./bin/flume-ng agent -c ./conf/ -f ./conf/log-kafka.properties -n agent -Dflume.root.logger=INFO,console

     

  • 相关阅读:
    [算法]全排列类问题
    windows下python安装Numpy和Scipy模块
    EMC校招笔试题目
    word2012写论文之参考文献和图片
    我的MBTI性格测试
    单例模式三境界
    css3滤镜Filter使用
    利用nginx 虚拟主机、请求转发实现不同端口web访问
    使用gitbook 发布一个教程文档网站
    linux 下CentOS 下 npm命令安装gitbook失败的问题
  • 原文地址:https://www.cnblogs.com/fengchuiguobanxia/p/16011339.html
Copyright © 2020-2023  润新知