美文网首页
Flume 日志采集器安装和部署

Flume 日志采集器安装和部署

作者: 晴空万里103804 | 来源:发表于2020-10-21 10:16 被阅读0次

    通过一个通道将来源和接收器连接,需要列出源,接收器和通道,为给定的代理,然后指向源和接收器及通道。一个源的实例可以指定多个通道,但只能指定一个接收器实例 。实时日志收集系统。

    参考:https://blog.csdn.net/dongdong9223/article/details/81482722

    Flume特点

    Flume是一个分布式、可靠和高可用的海量日志采集、聚合和传输的系统。支持在日志系统中定制各类数据发送方,用于收集数据。同时,flume提供对数据进行简单处理。并写到各种数据接收方(比如文本、HDFS、hbase)的能力

    Flume 的数据流是由Event(事件)贯穿始终的。Event是flume的基本数据单位,携带日志数据(字节数组形成)并且携带有头信息,这些Event由Agent外部的source生成,当source捕获事件后会进行特定的格式化,然后source会把事件推入(单个或多个)Channel中。其实可以把Channel看成一个缓冲区,将它将保存事件直到Sink处理完该事件。Sink负责持久化日志,比如保存到文本、HDFS、Hbase等,这是普通的Data flow model,如图所示:

    当然Flume也支持Multiplexing the flow,也就是多元化的数据流,将数据推向更多的目的地,包括目的地是另一个Source,如图所示:

    参考wiki 部署:

    https://cwiki.apache.org/confluence/display/FLUME/Getting+Started#space-menu-link-content

    实例测试

    使用arvo引入数据源

    将文件写入一个文本文件里,使用arvo将其引入到source中。

    新建agent配置文件

    conf/flume.conf

    配置如下:

    agent1.sources = avro-source1

    agent1.channels = ch1

    agent1.sinks = log-sink1

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

    agent1.sources.avro-source1.type = avro

    # The channel can be defined as follows.

    agent1.sources.avro-source1.channels = ch1

    agent1.sources.avro-source1.bind = 0.0.0.0

    agent1.sources.avro-source1.port = 41414

    # Each sink's type must be defined

    agent1.sinks.log-sink1.type = logger

    #Specify the channel the sink should use

    agent1.sinks.log-sink1.channel = ch1

    # Each channel's type is defined.

    agent1.channels.ch1.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

    agent1.channels.ch1.capacity = 100

    新建文件并写入内容

    echo 'Hello world2!' > ./test/log.00

    启动agent

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

    使用arvo-client发送文件

    ./bin/flume-ng avro-client -H localhost -p 41414 -F ../test/log.00

    在agent终端输出

    其他相关案例可参考:

    https://www.cnblogs.com/itdyb/p/6266789.html

    相关文章

      网友评论

          本文标题:Flume 日志采集器安装和部署

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