Flume学习8_Flume1.5.0入门:安装、部署、及flume的案例

flume安装与配置 1.解压 命名 tar zxvf /opt/apache-flume-1.6.0-bin.tar.gz -C /opt [root@master ~]#cd /opt/ [root@master ~]#mv apache-flume-1.6.0-bin/ flume 2.vi /etc/profile [root@master ~]#vi /etc/profile # 编辑系统环境变量配置文件 # set flume environment export FLUME_HOME=/usr 阅读详情
一、什么是Flume?
  flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应用。Flume 初始的发行版本目前被统称为 Flume OG(original generation),属于 cloudera。但随着 FLume 功能的扩展,Flume OG 代码工程臃肿、核心组件设计不合理、核心配置不标准等缺点暴露出来,尤其是在 Flume OG 的最后一个发行版本 0.94.0 中,日志传输不稳定的现象尤为严重,为了解决这些问题,2011 年 10 月 22 号,cloudera 完成了 Flume-728,对 Flume 进行了里程碑式的改动:重构核心组件、核心配置以及代码架构,重构后的版本统称为 Flume NG(next generation);改动的另一原因是将 Flume 纳入 apache 旗下,cloudera Flume 改名为 Apache Flume。

        flume的特点:
  flume是一个分布式、可靠、和高可用的海量日志采集、聚合和传输的系统。支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方(比如文本、HDFS、Hbase等)的能力 。
  flume的数据流由事件(Event)贯穿始终。事件是Flume的基本数据单位,它携带日志数据(字节数组形式)并且携带有头信息,这些Event由Agent外部的Source生成,当Source捕获事件后会进行特定的格式化,然后Source会把事件推入(单个或多个)Channel中。你可以把Channel看作是一个缓冲区,它将保存事件直到Sink处理完该事件。Sink负责持久化日志或者把事件推向另一个Source。

        flume的可靠性 
  当节点出现故障时,日志能够被传送到其他节点上而不会丢失。Flume提供了三种级别的可靠性保障,从强到弱依次分别为:end-to-end(收到数据agent首先将event写到磁盘上,当数据传送成功后,再删除;如果数据发送失败,可以重新发送。),Store on failure(这也是scribe采用的策略,当数据接收方crash时,将数据写到本地,待恢复后,继续发送),Besteffort(数据发送到接收方后,不会进行确认)。

        flume的可恢复性:
  还是靠Channel。推荐使用FileChannel,事件持久化在本地文件系统里(性能较差)。 

  flume的一些核心概念:
  • Agent        使用JVM 运行Flume。每台机器运行一个agent,但是可以在一个agent中包含多个sources和sinks。
  • Client        生产数据,运行在一个独立的线程。
  • Source        从Client收集数据,传递给Channel。
  • Sink        从Channel收集数据,运行在一个独立线程。
  • Channel        连接 sources 和 sinks ,这个有点像一个队列。
  • Events        可以是日志记录、 avro 对象等。


  Flume以agent为最小的独立运行单位。一个agent就是一个JVM。单agent由Source、Sink和Channel三大组件构成,如下图:

 


  值得注意的是,Flume提供了大量内置的Source、Channel和Sink类型。不同类型的Source,Channel和Sink可以自由组合。组合方式基于用户设置的配置文件,非常灵活。比如:Channel可以把事件暂存在内存里,也可以持久化到本地硬盘上。Sink可以把日志写入HDFS, HBase,甚至是另外一个Source等等。Flume支持用户建立多级流,也就是说,多个agent可以协同工作,并且支持Fan-in、Fan-out、Contextual Routing、Backup Routes,这也正是NB之处。如下图所示:

 



  二、flume的官方网站在哪里?
   http://flume.apache.org/

  三、在哪里下载?
   http://www.apache.org/dyn/closer.cgi/flume/1.5.0/apache-flume-1.5.0-bin.tar.gz

  四、如何安装?
    1)将下载的flume包,解压到/home/hadoop目录中,你就已经完成了50%:)简单吧
    2)修改 flume-env.sh 配置文件,主要是JAVA_HOME变量设置

  1. root@m1:/home/hadoop/flume-1.5.0-bin# cp conf/flume-env.sh.template conf/flume-env.sh
  2. root@m1:/home/hadoop/flume-1.5.0-bin# vi conf/flume-env.sh
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements.  See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership.  The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License.  You may obtain a copy of the License at
  10. #
  11. #     http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.

  18. # If this file is placed at FLUME_CONF_DIR/flume-env.sh, it will be sourced
  19. # during Flume startup.

  20. # Enviroment variables can be set here.

  21. JAVA_HOME=/usr/lib/jvm/java-7-oracle

  22. # Give Flume more memory and pre-allocate, enable remote monitoring via JMX
  23. #JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"

  24. # Note that the Flume conf directory is always included in the classpath.
  25. #FLUME_CLASSPATH=""
复制代码

              3)验证是否安装成功

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng version
  2. Flume 1.5.0
  3. Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
  4. Revision: 8633220df808c4cd0c13d1cf0320454a94f1ea97
  5. Compiled by hshreedharan on Wed May  7 14:49:18 PDT 2014
  6. From source with checksum a01fe726e4380ba0c9f7a7d222db961f
  7. root@m1:/home/hadoop#
复制代码
    出现上面的信息,表示安装成功了


  五、flume的案例
    1)案例1:Avro
    Avro可以发送一个给定的文件给Flume,Avro 源使用AVRO RPC机制。
      a)创建agent配置文件

  1. root@m1:/home/hadoop#vi /home/hadoop/flume-1.5.0-bin/conf/avro.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 4141

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码



      b)启动flume agent a1

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/avro.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)创建指定文件

  1. root@m1:/home/hadoop# echo "hello world" > /home/hadoop/flume-1.5.0-bin/log.00
复制代码

      d)使用avro-client发送文件

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng avro-client -c . -H m1 -p 4141 -F /home/hadoop/flume-1.5.0-bin/log.00
复制代码

      d)使用avro-client发送文件


  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng avro-client -c . -H m1 -p 4141 -F /
复制代码

      f)在m1的控制台,可以看到以下信息,注意最后一行:


  1. root@m1:/home/hadoop/flume-1.5.0-bin/conf# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/avro.conf -n a1 -Dflume.root.logger=INFO,console
  2. Info: Sourcing environment configuration script /home/hadoop/flume-1.5.0-bin/conf/flume-env.sh
  3. Info: Including Hadoop libraries found via (/home/hadoop/hadoop-2.2.0/bin/hadoop) for HDFS access
  4. Info: Excluding /home/hadoop/hadoop-2.2.0/share/hadoop/common/lib/slf4j-api-1.7.5.jar from classpath
  5. Info: Excluding /home/hadoop/hadoop-2.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar from classpath
  6. ...
  7. 2014-08-10 10:43:25,112 (New I/O  worker #1) [INFO - org.apache.avro.ipc.NettyServer$NettyServerAvroHandler.handleUpstream(NettyServer.java:171)] [id: 0x92464c4f, /192.168.1.50:59850 :> /192.168.1.50:4141] UNBOUND
  8. 2014-08-10 10:43:25,112 (New I/O  worker #1) [INFO - org.apache.avro.ipc.NettyServer$NettyServerAvroHandler.handleUpstream(NettyServer.java:171)] [id: 0x92464c4f, /192.168.1.50:59850 :> /192.168.1.50:4141] CLOSED
  9. 2014-08-10 10:43:25,112 (New I/O  worker #1) [INFO - org.apache.avro.ipc.NettyServer$NettyServerAvroHandler.channelClosed(NettyServer.java:209)] Connection to /192.168.1.50:59850 disconnected.
  10. 2014-08-10 10:43:26,718 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 68 65 6C 6C 6F 20 77 6F 72 6C 64                hello world }
复制代码


    2)案例2:Spool
    Spool监测配置的目录下新增的文件,并将文件中的数据读取出来。需要注意两点:
    1) 拷贝到spool目录下的文件不可以再打开编辑。
    2) spool目录下不可包含相应的子目录


      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/spool.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = spooldir
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.spoolDir = /home/hadoop/flume-1.5.0-bin/logs
  9. a1.sources.r1.fileHeader = true

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/spool.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)追加文件到/home/hadoop/flume-1.5.0-bin/logs目录

  1. root@m1:/home/hadoop# echo "spool test1" > /home/hadoop/flume-1.5.0-bin/logs/spool_text.log
复制代码

     d)在m1的控制台,可以看到以下相关信息:

  1. 14/08/10 11:37:13 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  2. 14/08/10 11:37:13 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  3. 14/08/10 11:37:14 INFO avro.ReliableSpoolingFileEventReader: Preparing to move file /home/hadoop/flume-1.5.0-bin/logs/spool_text.log to /home/hadoop/flume-1.5.0-bin/logs/spool_text.log.COMPLETED
  4. 14/08/10 11:37:14 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  5. 14/08/10 11:37:14 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  6. 14/08/10 11:37:14 INFO sink.LoggerSink: Event: { headers:{file=/home/hadoop/flume-1.5.0-bin/logs/spool_text.log} body: 73 70 6F 6F 6C 20 74 65 73 74 31                spool test1 }
  7. 14/08/10 11:37:15 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  8. 14/08/10 11:37:15 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  9. 14/08/10 11:37:16 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  10. 14/08/10 11:37:16 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
  11. 14/08/10 11:37:17 INFO source.SpoolDirectorySource: Spooling Directory Source runner has shutdown.
复制代码



    3)案例3:Exec
    EXEC执行一个给定的命令获得输出的源,如果要使用tail命令,必选使得file足够大才能看到输出内容

      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/exec_tail.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = exec
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.command = tail -F /home/hadoop/flume-1.5.0-bin/log_exec_tail

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

  11. # Use a channel which buffers events in memory
  12. a1.channels.c1.type = memory
  13. a1.channels.c1.capacity = 1000
  14. a1.channels.c1.transactionCapacity = 100

  15. # Bind the source and sink to the channel
  16. a1.sources.r1.channels = c1
  17. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/exec_tail.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)生成足够多的内容在文件里

  1. root@m1:/home/hadoop# for i in {1..100};do echo "exec tail$i" >> /home/hadoop/flume-1.5.0-bin/log_
复制代码

      e)在m1的控制台,可以看到以下信息:

  1. 2014-08-10 10:59:25,513 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 20 74 65 73 74       exec tail test }
  2. 2014-08-10 10:59:34,535 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 20 74 65 73 74       exec tail test }
  3. 2014-08-10 11:01:40,557 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 31                   exec tail1 }
  4. 2014-08-10 11:01:41,180 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 32                   exec tail2 }
  5. 2014-08-10 11:01:41,180 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 33                   exec tail3 }
  6. 2014-08-10 11:01:41,181 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 34                   exec tail4 }
  7. 2014-08-10 11:01:41,181 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 35                   exec tail5 }
  8. 2014-08-10 11:01:41,181 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 36                   exec tail6 }
  9. ....
  10. ....
  11. ....
  12. 2014-08-10 11:01:51,550 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 39 36                exec tail96 }
  13. 2014-08-10 11:01:51,550 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 39 37                exec tail97 }
  14. 2014-08-10 11:01:51,551 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 39 38                exec tail98 }
  15. 2014-08-10 11:01:51,551 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 39 39                exec tail99 }
  16. 2014-08-10 11:01:51,551 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 65 78 65 63 20 74 61 69 6C 31 30 30             exec tail100 }
复制代码



    4)案例4:Syslogtcp
    Syslogtcp监听TCP的端口做为数据源

      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/syslog_tcp.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = syslogtcp
  7. a1.sources.r1.port = 5140
  8. a1.sources.r1.host = localhost
  9. a1.sources.r1.channels = c1

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1


  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/syslog_tcp.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)测试产生syslog

  1. root@m1:/home/hadoop# echo "hello idoall.org syslog" | nc localhost 5140
复制代码

      d)在m1的控制台,可以看到以下信息:

  1. 14/08/10 11:41:45 INFO node.PollingPropertiesFileConfigurationProvider: Reloading configuration file:/home/hadoop/flume-1.5.0-bin/conf/syslog_tcp.conf
  2. 14/08/10 11:41:45 INFO conf.FlumeConfiguration: Added sinks: k1 Agent: a1
  3. 14/08/10 11:41:45 INFO conf.FlumeConfiguration: Processing:k1
  4. 14/08/10 11:41:45 INFO conf.FlumeConfiguration: Processing:k1
  5. 14/08/10 11:41:45 INFO conf.FlumeConfiguration: Post-validation flume configuration contains configuration for agents: [a1]
  6. 14/08/10 11:41:45 INFO node.AbstractConfigurationProvider: Creating channels
  7. 14/08/10 11:41:45 INFO channel.DefaultChannelFactory: Creating instance of channel c1 type memory
  8. 14/08/10 11:41:45 INFO node.AbstractConfigurationProvider: Created channel c1
  9. 14/08/10 11:41:45 INFO source.DefaultSourceFactory: Creating instance of source r1, type syslogtcp
  10. 14/08/10 11:41:45 INFO sink.DefaultSinkFactory: Creating instance of sink: k1, type: logger
  11. 14/08/10 11:41:45 INFO node.AbstractConfigurationProvider: Channel c1 connected to [r1, k1]
  12. 14/08/10 11:41:45 INFO node.Application: Starting new configuration:{ sourceRunners:{r1=EventDrivenSourceRunner: { source:org.apache.flume.source.SyslogTcpSource{name:r1,state:IDLE} }} sinkRunners:{k1=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@6538b14 counterGroup:{ name:null counters:{} } }} channels:{c1=org.apache.flume.channel.MemoryChannel{name: c1}} }
  13. 14/08/10 11:41:45 INFO node.Application: Starting Channel c1
  14. 14/08/10 11:41:45 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: CHANNEL, name: c1: Successfully registered new MBean.
  15. 14/08/10 11:41:45 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: c1 started
  16. 14/08/10 11:41:45 INFO node.Application: Starting Sink k1
  17. 14/08/10 11:41:45 INFO node.Application: Starting Source r1
  18. 14/08/10 11:41:45 INFO source.SyslogTcpSource: Syslog TCP Source starting...
  19. 14/08/10 11:42:15 WARN source.SyslogUtils: Event created from Invalid Syslog data.
  20. 14/08/10 11:42:15 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 68 65 6C 6C 6F 20 69 64 6F 61 6C 6C 2E 6F 72 67 hello idoall.org }
复制代码



    5)案例5:JSONHandler
      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/post_json.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
  7. a1.sources.r1.port = 8888
  8. a1.sources.r1.channels = c1

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

  11. # Use a channel which buffers events in memory
  12. a1.channels.c1.type = memory
  13. a1.channels.c1.capacity = 1000
  14. a1.channels.c1.transactionCapacity = 100

  15. # Bind the source and sink to the channel
  16. a1.sources.r1.channels = c1
  17. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1


  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/post_json.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)生成JSON 格式的POST request

  1. root@m1:/home/hadoop# curl -X POST -d '[{ "headers" :{"a" : "a1","b" : "b1"},"body" : "idoall.org_body"}]' http://localhost:8888
复制代码

      d)在m1的控制台,可以看到以下信息:

  1. 14/08/10 11:49:59 INFO node.Application: Starting Channel c1
  2. 14/08/10 11:49:59 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: CHANNEL, name: c1: Successfully registered new MBean.
  3. 14/08/10 11:49:59 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: c1 started
  4. 14/08/10 11:49:59 INFO node.Application: Starting Sink k1
  5. 14/08/10 11:49:59 INFO node.Application: Starting Source r1
  6. 14/08/10 11:49:59 INFO mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
  7. 14/08/10 11:49:59 INFO mortbay.log: jetty-6.1.26
  8. 14/08/10 11:50:00 INFO mortbay.log: Started SelectChannelConnector@0.0.0.0:8888
  9. 14/08/10 11:50:00 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SOURCE, name: r1: Successfully registered new MBean.
  10. 14/08/10 11:50:00 INFO instrumentation.MonitoredCounterGroup: Component type: SOURCE, name: r1 started
  11. 14/08/10 12:14:32 INFO sink.LoggerSink: Event: { headers:{b=b1, a=a1} body: 69 64 6F 61 6C 6C 2E 6F 72 67 5F 62 6F 64 79    idoall.org_body }
复制代码

    6)案例6:Hadoop sink
      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/hdfs_sink.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = syslogtcp
  7. a1.sources.r1.port = 5140
  8. a1.sources.r1.host = localhost
  9. a1.sources.r1.channels = c1

  10. # Describe the sink
  11. a1.sinks.k1.type = hdfs
  12. a1.sinks.k1.channel = c1
  13. a1.sinks.k1.hdfs.path = hdfs://m1:9000/user/flume/syslogtcp
  14. a1.sinks.k1.hdfs.filePrefix = Syslog
  15. a1.sinks.k1.hdfs.round = true
  16. a1.sinks.k1.hdfs.roundValue = 10
  17. a1.sinks.k1.hdfs.roundUnit = minute

  18. # Use a channel which buffers events in memory
  19. a1.channels.c1.type = memory
  20. a1.channels.c1.capacity = 1000
  21. a1.channels.c1.transactionCapacity = 100

  22. # Bind the source and sink to the channel
  23. a1.sources.r1.channels = c1
  24. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/hdfs_sink.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)测试产生syslog

  1. root@m1:/home/hadoop# echo "hello idoall flume -> hadoop testing one" | nc localhost 5140
复制代码

      d)在m1的控制台,可以看到以下信息:

  1. 14/08/10 12:20:39 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: CHANNEL, name: c1: Successfully registered new MBean.
  2. 14/08/10 12:20:39 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: c1 started
  3. 14/08/10 12:20:39 INFO node.Application: Starting Sink k1
  4. 14/08/10 12:20:39 INFO node.Application: Starting Source r1
  5. 14/08/10 12:20:39 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SINK, name: k1: Successfully registered new MBean.
  6. 14/08/10 12:20:39 INFO instrumentation.MonitoredCounterGroup: Component type: SINK, name: k1 started
  7. 14/08/10 12:20:39 INFO source.SyslogTcpSource: Syslog TCP Source starting...
  8. 14/08/10 12:21:46 WARN source.SyslogUtils: Event created from Invalid Syslog data.
  9. 14/08/10 12:21:49 INFO hdfs.HDFSSequenceFile: writeFormat = Writable, UseRawLocalFileSystem = false
  10. 14/08/10 12:21:49 INFO hdfs.BucketWriter: Creating hdfs://m1:9000/user/flume/syslogtcp//Syslog.1407644509504.tmp
  11. 14/08/10 12:22:20 INFO hdfs.BucketWriter: Closing hdfs://m1:9000/user/flume/syslogtcp//Syslog.1407644509504.tmp
  12. 14/08/10 12:22:20 INFO hdfs.BucketWriter: Close tries incremented
  13. 14/08/10 12:22:20 INFO hdfs.BucketWriter: Renaming hdfs://m1:9000/user/flume/syslogtcp/Syslog.1407644509504.tmp to hdfs://m1:9000/user/flume/syslogtcp/Syslog.1407644509504
  14. 14/08/10 12:22:20 INFO hdfs.HDFSEventSink: Writer callback called.
复制代码

      e)在m1上再打开一个窗口,去hadoop上检查文件是否生成

  1. root@m1:/home/hadoop# /home/hadoop/hadoop-2.2.0/bin/hadoop fs -ls /user/flume/syslogtcp
  2. Found 1 items
  3. -rw-r--r--   3 root supergroup        155 2014-08-10 12:22 /user/flume/syslogtcp/Syslog.1407644509504
  4. root@m1:/home/hadoop# /home/hadoop/hadoop-2.2.0/bin/hadoop fs -cat /user/flume/syslogtcp/Syslog.1407644509504
  5. SEQ!org.apache.hadoop.io.LongWritable"org.apache.hadoop.io.BytesWritable^;>Gv$hello idoall flume -> hadoop testing one
复制代码



    7)案例7:File Roll Sink
      a)创建agent配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/file_roll.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = syslogtcp
  7. a1.sources.r1.port = 5555
  8. a1.sources.r1.host = localhost
  9. a1.sources.r1.channels = c1

  10. # Describe the sink
  11. a1.sinks.k1.type = file_roll
  12. a1.sinks.k1.sink.directory = /home/hadoop/flume-1.5.0-bin/logs

  13. # Use a channel which buffers events in memory
  14. a1.channels.c1.type = memory
  15. a1.channels.c1.capacity = 1000
  16. a1.channels.c1.transactionCapacity = 100

  17. # Bind the source and sink to the channel
  18. a1.sources.r1.channels = c1
  19. a1.sinks.k1.channel = c1
复制代码

      b)启动flume agent a1

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/file_roll.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      c)测试产生log

  1. root@m1:/home/hadoop# echo "hello idoall.org syslog" | nc localhost 5555
  2. root@m1:/home/hadoop# echo "hello idoall.org syslog 2" | nc localhost 5555
复制代码

      d)查看/home/hadoop/flume-1.5.0-bin/logs下是否生成文件,默认每30秒生成一个新文件

  1. root@m1:/home/hadoop# ll /home/hadoop/flume-1.5.0-bin/logs
  2. 总用量 272
  3. drwxr-xr-x 3 root root   4096 Aug 10 12:50 ./
  4. drwxr-xr-x 9 root root   4096 Aug 10 10:59 ../
  5. -rw-r--r-- 1 root root     50 Aug 10 12:49 1407646164782-1
  6. -rw-r--r-- 1 root root      0 Aug 10 12:49 1407646164782-2
  7. -rw-r--r-- 1 root root      0 Aug 10 12:50 1407646164782-3
  8. root@m1:/home/hadoop# cat /home/hadoop/flume-1.5.0-bin/logs/1407646164782-1 /home/hadoop/flume-1.5.0-bin/logs/1407646164782-2
  9. hello idoall.org syslog
  10. hello idoall.org syslog 2
复制代码



    8)案例8:Replicating Channel Selector
    Flume支持Fan out流从一个源到多个通道。有两种模式的Fan out,分别是复制和复用。在复制的情况下,流的事件被发送到所有的配置通道。在复用的情况下,事件被发送到可用的渠道中的一个子集。Fan out流需要指定源和Fan out通道的规则。

    这次我们需要用到m1,m2两台机器

      a)在m1创建replicating_Channel_Selector配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector.conf

  2. a1.sources = r1
  3. a1.sinks = k1 k2
  4. a1.channels = c1 c2

  5. # Describe/configure the source
  6. a1.sources.r1.type = syslogtcp
  7. a1.sources.r1.port = 5140
  8. a1.sources.r1.host = localhost
  9. a1.sources.r1.channels = c1 c2
  10. a1.sources.r1.selector.type = replicating

  11. # Describe the sink
  12. a1.sinks.k1.type = avro
  13. a1.sinks.k1.channel = c1
  14. a1.sinks.k1.hostname = m1
  15. a1.sinks.k1.port = 5555

  16. a1.sinks.k2.type = avro
  17. a1.sinks.k2.channel = c2
  18. a1.sinks.k2.hostname = m2
  19. a1.sinks.k2.port = 5555

  20. # Use a channel which buffers events in memory
  21. a1.channels.c1.type = memory
  22. a1.channels.c1.capacity = 1000
  23. a1.channels.c1.transactionCapacity = 100

  24. a1.channels.c2.type = memory
  25. a1.channels.c2.capacity = 1000
  26. a1.channels.c2.transactionCapacity = 100
复制代码

      b)在m1创建replicating_Channel_Selector_avro配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector_avro.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 5555

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码

      c)在m1上将2个配置文件复制到m2上一份
  1. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector.conf root@m2:/home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector.conf
  2. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector_avro.conf root@m2:/home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector_avro.conf
复制代码
      d)打开4个窗口,在m1和m2上同时启动两个flume agent
  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector_avro.conf -n a1 -Dflume.root.logger=INFO,console
  2. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/replicating_Channel_Selector.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      e)然后在m1或m2的任意一台机器上,测试产生syslog
  1. root@m1:/home/hadoop# echo "hello idoall.org syslog" | nc localhost 5140
复制代码

      f)在m1和m2的sink窗口,分别可以看到以下信息,这说明信息得到了同步:
  1. 14/08/10 14:08:18 INFO ipc.NettyServer: Connection to /192.168.1.51:46844 disconnected.
  2. 14/08/10 14:08:52 INFO ipc.NettyServer: [id: 0x90f8fe1f, /192.168.1.50:35873 => /192.168.1.50:5555] OPEN
  3. 14/08/10 14:08:52 INFO ipc.NettyServer: [id: 0x90f8fe1f, /192.168.1.50:35873 => /192.168.1.50:5555] BOUND: /192.168.1.50:5555
  4. 14/08/10 14:08:52 INFO ipc.NettyServer: [id: 0x90f8fe1f, /192.168.1.50:35873 => /192.168.1.50:5555] CONNECTED: /192.168.1.50:35873
  5. 14/08/10 14:08:59 INFO ipc.NettyServer: [id: 0xd6318635, /192.168.1.51:46858 => /192.168.1.50:5555] OPEN
  6. 14/08/10 14:08:59 INFO ipc.NettyServer: [id: 0xd6318635, /192.168.1.51:46858 => /192.168.1.50:5555] BOUND: /192.168.1.50:5555
  7. 14/08/10 14:08:59 INFO ipc.NettyServer: [id: 0xd6318635, /192.168.1.51:46858 => /192.168.1.50:5555] CONNECTED: /192.168.1.51:46858
  8. 14/08/10 14:09:20 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 68 65 6C 6C 6F 20 69 64 6F 61 6C 6C 2E 6F 72 67 hello idoall.org }
复制代码



    9)案例9:Multiplexing Channel Selector
      a)在m1创建Multiplexing_Channel_Selector配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector.conf

  2. a1.sources = r1
  3. a1.sinks = k1 k2
  4. a1.channels = c1 c2

  5. # Describe/configure the source
  6. a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
  7. a1.sources.r1.port = 5140
  8. a1.sources.r1.channels = c1 c2
  9. a1.sources.r1.selector.type = multiplexing

  10. a1.sources.r1.selector.header = type
  11. #映射允许每个值通道可以重叠。默认值可以包含任意数量的通道。
  12. a1.sources.r1.selector.mapping.baidu = c1
  13. a1.sources.r1.selector.mapping.ali = c2
  14. a1.sources.r1.selector.default = c1

  15. # Describe the sink
  16. a1.sinks.k1.type = avro
  17. a1.sinks.k1.channel = c1
  18. a1.sinks.k1.hostname = m1
  19. a1.sinks.k1.port = 5555

  20. a1.sinks.k2.type = avro
  21. a1.sinks.k2.channel = c2
  22. a1.sinks.k2.hostname = m2
  23. a1.sinks.k2.port = 5555

  24. # Use a channel which buffers events in memory
  25. a1.channels.c1.type = memory
  26. a1.channels.c1.capacity = 1000
  27. a1.channels.c1.transactionCapacity = 100

  28. a1.channels.c2.type = memory
  29. a1.channels.c2.capacity = 1000
  30. a1.channels.c2.transactionCapacity = 100
复制代码



      b)在m1创建Multiplexing_Channel_Selector_avro配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector_avro.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 5555

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码



      c)将2个配置文件复制到m2上一份
  1. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector.conf  root@m2:/home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector.conf
  2. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector_avro.conf root@m2:/home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector_avro.conf
复制代码



      d)打开4个窗口,在m1和m2上同时启动两个flume agent
  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector_avro.conf -n a1 -Dflume.root.logger=INFO,console
  2. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Multiplexing_Channel_Selector.conf -n a1 -Dflume.root.logger=INFO,console
复制代码



      e)然后在m1或m2的任意一台机器上,测试产生syslog
  1. root@m1:/home/hadoop# curl -X POST -d '[{ "headers" :{"type" : "baidu"},"body" : "idoall_TEST1"}]' http://localhost:5140 && curl -X POST -d '[{ "headers" :{"type" : "ali"},"body" : "idoall_TEST2"}]' http://localhost:5140 && curl -X POST -d '[{ "headers" :{"type" : "qq"},"body" : "idoall_TEST3"}]' http://localhost:5140
复制代码

     f)在m1的sink窗口,可以看到以下信息:
  1. 14/08/10 14:32:21 INFO node.Application: Starting Sink k1
  2. 14/08/10 14:32:21 INFO node.Application: Starting Source r1
  3. 14/08/10 14:32:21 INFO source.AvroSource: Starting Avro source r1: { bindAddress: 0.0.0.0, port: 5555 }...
  4. 14/08/10 14:32:21 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SOURCE, name: r1: Successfully registered new MBean.
  5. 14/08/10 14:32:21 INFO instrumentation.MonitoredCounterGroup: Component type: SOURCE, name: r1 started
  6. 14/08/10 14:32:21 INFO source.AvroSource: Avro source r1 started.
  7. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0xcf00eea6, /192.168.1.50:35916 => /192.168.1.50:5555] OPEN
  8. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0xcf00eea6, /192.168.1.50:35916 => /192.168.1.50:5555] BOUND: /192.168.1.50:5555
  9. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0xcf00eea6, /192.168.1.50:35916 => /192.168.1.50:5555] CONNECTED: /192.168.1.50:35916
  10. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x432f5468, /192.168.1.51:46945 => /192.168.1.50:5555] OPEN
  11. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x432f5468, /192.168.1.51:46945 => /192.168.1.50:5555] BOUND: /192.168.1.50:5555
  12. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x432f5468, /192.168.1.51:46945 => /192.168.1.50:5555] CONNECTED: /192.168.1.51:46945
  13. 14/08/10 14:34:11 INFO sink.LoggerSink: Event: { headers:{type=baidu} body: 69 64 6F 61 6C 6C 5F 54 45 53 54 31             idoall_TEST1 }
  14. 14/08/10 14:34:57 INFO sink.LoggerSink: Event: { headers:{type=qq} body: 69 64 6F 61 6C 6C 5F 54 45 53 54 33             idoall_TEST3 }
复制代码

     g)在m2的sink窗口,可以看到以下信息:

  1. 14/08/10 14:32:27 INFO node.Application: Starting Sink k1
  2. 14/08/10 14:32:27 INFO node.Application: Starting Source r1
  3. 14/08/10 14:32:27 INFO source.AvroSource: Starting Avro source r1: { bindAddress: 0.0.0.0, port: 5555 }...
  4. 14/08/10 14:32:27 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SOURCE, name: r1: Successfully registered new MBean.
  5. 14/08/10 14:32:27 INFO instrumentation.MonitoredCounterGroup: Component type: SOURCE, name: r1 started
  6. 14/08/10 14:32:27 INFO source.AvroSource: Avro source r1 started.
  7. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0x7c2f0aec, /192.168.1.50:38104 => /192.168.1.51:5555] OPEN
  8. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0x7c2f0aec, /192.168.1.50:38104 => /192.168.1.51:5555] BOUND: /192.168.1.51:5555
  9. 14/08/10 14:32:36 INFO ipc.NettyServer: [id: 0x7c2f0aec, /192.168.1.50:38104 => /192.168.1.51:5555] CONNECTED: /192.168.1.50:38104
  10. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x3d36f553, /192.168.1.51:48599 => /192.168.1.51:5555] OPEN
  11. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x3d36f553, /192.168.1.51:48599 => /192.168.1.51:5555] BOUND: /192.168.1.51:5555
  12. 14/08/10 14:32:44 INFO ipc.NettyServer: [id: 0x3d36f553, /192.168.1.51:48599 => /192.168.1.51:5555] CONNECTED: /192.168.1.51:48599
  13. 14/08/10 14:34:33 INFO sink.LoggerSink: Event: { headers:{type=ali} body: 69 64 6F 61 6C 6C 5F 54 45 53 54 32             idoall_TEST2 }
复制代码



    可以看到,根据header中不同的条件分布到不同的channel上

    10)案例10:Flume Sink Processors
    failover的机器是一直发送给其中一个sink,当这个sink不可用的时候,自动发送到下一个sink。

      a)在m1创建Flume_Sink_Processors配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors.conf

  2. a1.sources = r1
  3. a1.sinks = k1 k2
  4. a1.channels = c1 c2

  5. #这个是配置failover的关键,需要有一个sink group
  6. a1.sinkgroups = g1
  7. a1.sinkgroups.g1.sinks = k1 k2
  8. #处理的类型是failover
  9. a1.sinkgroups.g1.processor.type = failover
  10. #优先级,数字越大优先级越高,每个sink的优先级必须不相同
  11. a1.sinkgroups.g1.processor.priority.k1 = 5
  12. a1.sinkgroups.g1.processor.priority.k2 = 10
  13. #设置为10秒,当然可以根据你的实际状况更改成更快或者很慢
  14. a1.sinkgroups.g1.processor.maxpenalty = 10000

  15. # Describe/configure the source
  16. a1.sources.r1.type = syslogtcp
  17. a1.sources.r1.port = 5140
  18. a1.sources.r1.channels = c1 c2
  19. a1.sources.r1.selector.type = replicating


  20. # Describe the sink
  21. a1.sinks.k1.type = avro
  22. a1.sinks.k1.channel = c1
  23. a1.sinks.k1.hostname = m1
  24. a1.sinks.k1.port = 5555

  25. a1.sinks.k2.type = avro
  26. a1.sinks.k2.channel = c2
  27. a1.sinks.k2.hostname = m2
  28. a1.sinks.k2.port = 5555

  29. # Use a channel which buffers events in memory
  30. a1.channels.c1.type = memory
  31. a1.channels.c1.capacity = 1000
  32. a1.channels.c1.transactionCapacity = 100

  33. a1.channels.c2.type = memory
  34. a1.channels.c2.capacity = 1000
  35. a1.channels.c2.transactionCapacity = 100
复制代码

      b)在m1创建Flume_Sink_Processors_avro配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors_avro.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 5555

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码

      c)将2个配置文件复制到m2上一份
  1. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors.conf  root@m2:/home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors.conf
  2. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors_avro.conf root@m2:/home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors_avro.conf
复制代码

      d)打开4个窗口,在m1和m2上同时启动两个flume agent
  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors_avro.conf -n a1 -Dflume.root.logger=INFO,console
  2. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      e)然后在m1或m2的任意一台机器上,测试产生log
  1. root@m1:/home/hadoop# echo "idoall.org test1 failover" | nc localhost 5140
复制代码

      f)因为m2的优先级高,所以在m2的sink窗口,可以看到以下信息,而m1没有:
  1. 14/08/10 15:02:46 INFO ipc.NettyServer: Connection to /192.168.1.51:48692 disconnected.
  2. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0x09a14036, /192.168.1.51:48704 => /192.168.1.51:5555] OPEN
  3. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0x09a14036, /192.168.1.51:48704 => /192.168.1.51:5555] BOUND: /192.168.1.51:5555
  4. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0x09a14036, /192.168.1.51:48704 => /192.168.1.51:5555] CONNECTED: /192.168.1.51:48704
  5. 14/08/10 15:03:26 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 31 idoall.org test1 }
复制代码

      g)这时我们停止掉m2机器上的sink(ctrl+c),再次输出测试数据:
  1. root@m1:/home/hadoop# echo "idoall.org test2 failover" | nc localhost 5140
复制代码

      h)可以在m1的sink窗口,看到读取到了刚才发送的两条测试数据:
  1. 14/08/10 15:02:46 INFO ipc.NettyServer: Connection to /192.168.1.51:47036 disconnected.
  2. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0xbcf79851, /192.168.1.51:47048 => /192.168.1.50:5555] OPEN
  3. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0xbcf79851, /192.168.1.51:47048 => /192.168.1.50:5555] BOUND: /192.168.1.50:5555
  4. 14/08/10 15:03:12 INFO ipc.NettyServer: [id: 0xbcf79851, /192.168.1.51:47048 => /192.168.1.50:5555] CONNECTED: /192.168.1.51:47048
  5. 14/08/10 15:07:56 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 31 idoall.org test1 }
  6. 14/08/10 15:07:56 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 32 idoall.org test2 }
复制代码

      i)我们再在m2的sink窗口中,启动sink:
  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Flume_Sink_Processors_avro.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      j)输入两批测试数据:
  1. root@m1:/home/hadoop# echo "idoall.org test3 failover" | nc localhost 5140 && echo "idoall.org test4 failover" | nc localhost 5140
复制代码

     k)在m2的sink窗口,我们可以看到以下信息,因为优先级的关系,log消息会再次落到m2上:
  1. 14/08/10 15:09:47 INFO node.Application: Starting Sink k1
  2. 14/08/10 15:09:47 INFO node.Application: Starting Source r1
  3. 14/08/10 15:09:47 INFO source.AvroSource: Starting Avro source r1: { bindAddress: 0.0.0.0, port: 5555 }...
  4. 14/08/10 15:09:47 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SOURCE, name: r1: Successfully registered new MBean.
  5. 14/08/10 15:09:47 INFO instrumentation.MonitoredCounterGroup: Component type: SOURCE, name: r1 started
  6. 14/08/10 15:09:47 INFO source.AvroSource: Avro source r1 started.
  7. 14/08/10 15:09:54 INFO ipc.NettyServer: [id: 0x96615732, /192.168.1.51:48741 => /192.168.1.51:5555] OPEN
  8. 14/08/10 15:09:54 INFO ipc.NettyServer: [id: 0x96615732, /192.168.1.51:48741 => /192.168.1.51:5555] BOUND: /192.168.1.51:5555
  9. 14/08/10 15:09:54 INFO ipc.NettyServer: [id: 0x96615732, /192.168.1.51:48741 => /192.168.1.51:5555] CONNECTED: /192.168.1.51:48741
  10. 14/08/10 15:09:57 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 32 idoall.org test2 }
  11. 14/08/10 15:10:43 INFO ipc.NettyServer: [id: 0x12621f9a, /192.168.1.50:38166 => /192.168.1.51:5555] OPEN
  12. 14/08/10 15:10:43 INFO ipc.NettyServer: [id: 0x12621f9a, /192.168.1.50:38166 => /192.168.1.51:5555] BOUND: /192.168.1.51:5555
  13. 14/08/10 15:10:43 INFO ipc.NettyServer: [id: 0x12621f9a, /192.168.1.50:38166 => /192.168.1.51:5555] CONNECTED: /192.168.1.50:38166
  14. 14/08/10 15:10:43 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 33 idoall.org test3 }
  15. 14/08/10 15:10:43 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 34 idoall.org test4 }
复制代码



    11)案例11:Load balancing Sink Processor
    load balance type和failover不同的地方是,load balance有两个配置,一个是轮询,一个是随机。两种情况下如果被选择的sink不可用,就会自动尝试发送到下一个可用的sink上面。

      a)在m1创建Load_balancing_Sink_Processors配置文件

  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors.conf

  2. a1.sources = r1
  3. a1.sinks = k1 k2
  4. a1.channels = c1

  5. #这个是配置Load balancing的关键,需要有一个sink group
  6. a1.sinkgroups = g1
  7. a1.sinkgroups.g1.sinks = k1 k2
  8. a1.sinkgroups.g1.processor.type = load_balance
  9. a1.sinkgroups.g1.processor.backoff = true
  10. a1.sinkgroups.g1.processor.selector = round_robin

  11. # Describe/configure the source
  12. a1.sources.r1.type = syslogtcp
  13. a1.sources.r1.port = 5140
  14. a1.sources.r1.channels = c1


  15. # Describe the sink
  16. a1.sinks.k1.type = avro
  17. a1.sinks.k1.channel = c1
  18. a1.sinks.k1.hostname = m1
  19. a1.sinks.k1.port = 5555

  20. a1.sinks.k2.type = avro
  21. a1.sinks.k2.channel = c1
  22. a1.sinks.k2.hostname = m2
  23. a1.sinks.k2.port = 5555

  24. # Use a channel which buffers events in memory
  25. a1.channels.c1.type = memory
  26. a1.channels.c1.capacity = 1000
  27. a1.channels.c1.transactionCapacity = 100
复制代码



      b)在m1创建Load_balancing_Sink_Processors_avro配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors_avro.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = avro
  7. a1.sources.r1.channels = c1
  8. a1.sources.r1.bind = 0.0.0.0
  9. a1.sources.r1.port = 5555

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

  12. # Use a channel which buffers events in memory
  13. a1.channels.c1.type = memory
  14. a1.channels.c1.capacity = 1000
  15. a1.channels.c1.transactionCapacity = 100

  16. # Bind the source and sink to the channel
  17. a1.sources.r1.channels = c1
  18. a1.sinks.k1.channel = c1
复制代码

      c)将2个配置文件复制到m2上一份
  1. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors.conf  root@m2:/home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors.conf
  2. root@m1:/home/hadoop/flume-1.5.0-bin# scp -r /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors_avro.conf root@m2:/home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors_avro.conf
复制代码

      d)打开4个窗口,在m1和m2上同时启动两个flume agent

  1. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors_avro.conf -n a1 -Dflume.root.logger=INFO,console
  2. root@m1:/home/hadoop# /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/Load_balancing_Sink_Processors.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      e)然后在m1或m2的任意一台机器上,测试产生log,一行一行输入,输入太快,容易落到一台机器上
  1. root@m1:/home/hadoop# echo "idoall.org test1" | nc localhost 5140
  2. root@m1:/home/hadoop# echo "idoall.org test2" | nc localhost 5140
  3. root@m1:/home/hadoop# echo "idoall.org test3" | nc localhost 5140
  4. root@m1:/home/hadoop# echo "idoall.org test4" | nc localhost 5140
复制代码

      f)在m1的sink窗口,可以看到以下信息:
  1. 14/08/10 15:35:29 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 32 idoall.org test2 }
  2. 14/08/10 15:35:33 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 34 idoall.org test4 }
复制代码

      g)在m2的sink窗口,可以看到以下信息:
  1. 14/08/10 15:35:27 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 31 idoall.org test1 }
  2. 14/08/10 15:35:29 INFO sink.LoggerSink: Event: { headers:{Severity=0, flume.syslog.status=Invalid, Facility=0} body: 69 64 6F 61 6C 6C 2E 6F 72 67 20 74 65 73 74 33 idoall.org test3 }
复制代码



    说明轮询模式起到了作用。

    12)案例12:Hbase sink


      a)在测试之前,请先参考《 ubuntu12.04+hadoop2.2.0+zookeeper3.4.5+hbase0.96.2+hive0.13.1分布式环境部署 》将hbase启动

      b)然后将以下文件复制到flume中:

  1. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/protobuf-java-2.5.0.jar /home/hadoop/flume-1.5.0-bin/lib
  2. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-client-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib
  3. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-common-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib
  4. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-protocol-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib
  5. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-server-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib
  6. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-hadoop2-compat-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib
  7. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/hbase-hadoop-compat-0.96.2-hadoop2.jar /home/hadoop/flume-1.5.0-bin/lib@@@
  8. cp /home/hadoop/hbase-0.96.2-hadoop2/lib/htrace-core-2.04.jar /home/hadoop/flume-1.5.0-bin/lib
复制代码

      c)确保test_idoall_org表在hbase中已经存在

      d)在m1创建hbase_simple配置文件
  1. root@m1:/home/hadoop# vi /home/hadoop/flume-1.5.0-bin/conf/hbase_simple.conf

  2. a1.sources = r1
  3. a1.sinks = k1
  4. a1.channels = c1

  5. # Describe/configure the source
  6. a1.sources.r1.type = syslogtcp
  7. a1.sources.r1.port = 5140
  8. a1.sources.r1.host = localhost
  9. a1.sources.r1.channels = c1

  10. # Describe the sink
  11. a1.sinks.k1.type = logger
  12. a1.sinks.k1.type = hbase
  13. a1.sinks.k1.table = test_idoall_org
  14. a1.sinks.k1.columnFamily = name
  15. a1.sinks.k1.column = idoall
  16. a1.sinks.k1.serializer =  org.apache.flume.sink.hbase.RegexHbaseEventSerializer
  17. a1.sinks.k1.channel = memoryChannel

  18. # Use a channel which buffers events in memory
  19. a1.channels.c1.type = memory
  20. a1.channels.c1.capacity = 1000
  21. a1.channels.c1.transactionCapacity = 100

  22. # Bind the source and sink to the channel
  23. a1.sources.r1.channels = c1
  24. a1.sinks.k1.channel = c1
复制代码

      e)启动flume agent
  1. /home/hadoop/flume-1.5.0-bin/bin/flume-ng agent -c . -f /home/hadoop/flume-1.5.0-bin/conf/hbase_simple.conf -n a1 -Dflume.root.logger=INFO,console
复制代码

      f)测试产生syslog
  1. root@m1:/home/hadoop# echo "hello idoall.org from flume" | nc localhost 5140
复制代码

      g)这时登录到hbase中,可以发现新数据已经插入
  1. root@m1:/home/hadoop# /home/hadoop/hbase-0.96.2-hadoop2/bin/hbase shell
  2. 2014-08-10 16:09:48,984 INFO  [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
  3. HBase Shell; enter 'help<RETURN>' for list of supported commands.
  4. Type "exit<RETURN>" to leave the HBase Shell
  5. Version 0.96.2-hadoop2, r1581096, Mon Mar 24 16:03:18 PDT 2014

  6. hbase(main):001:0> list
  7. TABLE                                                                                                                                                                                                                  
  8. SLF4J: Class path contains multiple SLF4J bindings.
  9. SLF4J: Found binding in [jar:file:/home/hadoop/hbase-0.96.2-hadoop2/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  10. SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  11. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  12. hbase2hive_idoall                                                                                                                                                                                                      
  13. hive2hbase_idoall                                                                                                                                                                                                      
  14. test_idoall_org                                                                                                                                                                                                        
  15. 3 row(s) in 2.6880 seconds

  16. => ["hbase2hive_idoall", "hive2hbase_idoall", "test_idoall_org"]
  17. hbase(main):002:0> scan "test_idoall_org"
  18. ROW                                                    COLUMN+CELL                                                                                                                                                     
  19. 10086                                                 column=name:idoall, timestamp=1406424831473, value=idoallvalue                                                                                                  
  20. 1 row(s) in 0.0550 seconds

  21. hbase(main):003:0> scan "test_idoall_org"
  22. ROW                                                    COLUMN+CELL                                                                                                                                                     
  23. 10086                                                 column=name:idoall, timestamp=1406424831473, value=idoallvalue                                                                                                  
  24. 1407658495588-XbQCOZrKK8-0                            column=name:payload, timestamp=1407658498203, value=hello idoall.org from flume                                                                                 
  25. 2 row(s) in 0.0200 seconds

  26. hbase(main):004:0> quit
复制代码

经过这么多flume的例子测试,如果你全部做完后,会发现flume的功能真的很强大,可以进行各种搭配来完成你想要的工作,俗话说师傅领进门,修行在个人,如何能够结合你的产品业务,将flume更好的应用起来,快去动手实践吧。


原文来自:http://www.aboutyun.com/thread-8917-1-1.html

Flume安装——环境搭建(二) 文章目录前言1 Flume安装地址2 安装部署 前言 大家好,我是爱做梦的鱼,我是东北大学大数据实验班大三的小菜鸡,非常渴望优秀,羡慕优秀的人。从5月25号我们开始了为期两个月的实习,我们需要做一个大型大数据项目,一个项目由三个学生+一个企业的项目经理完成。请大家持续关注我的专栏,我会每天更新。 专栏:大数据案例实战——大三春招大数据开发 这是我的博客地址:子浩的博客https://blog.csdn.net/weixin_43124279 欢迎大家关注微信公众号【程序猿干货铺】 该公众号由一群仰望星 阅读详情

相关推荐

手把手教你设计2bit反射型超表面:从单patch扫参到pin管配置全流程

本文提供了一份2bit反射型超表面设计的完整工程实践指南。从单贴片谐振器的参数化扫描与“270度法则”应用,到PIN二极管等效电路模型的获取与集成,再到利用参数化扫描高效仿真四种工作状态,手把手指导读者完成从单元设计到阵列布局、偏置线集成及加工考量的全流程,旨在帮助射频工程师将概念转化为可加工测试的实体模型。

java5的博客 1028

Vivado多线程加速

参考Vivado中jobs和threads的区别?选择多个jobs能加快实现速度么? 可以得知在综合,实现和生成bit文件中,Number of jobs并不能加快速度,只是设置同时运行的最大runs。 对于多线程而言,应该通过tcl进行设置。 通过 report_param general.maxThreads report_param synth.maxThreads 可以看到 report_param synth.maxThreads Name Value Type

I_LOVE_MCU的博客 4375

基于深度学习的高精度牙齿健康检测识别系统(PyTorch+Pyside6+YOLOv5模型)

近年来,机器学习和深度学习取得了较大的发展,深度学习方法在检测精度和速度方面与传统方法相比表现出更良好的性能。YOLOv5是单阶段目标检测算法YOLO的第五代,根据实验得出结论,其在速度与准确性能方面都有了明显提升,开源的代码可见https://github.com/ultralytics/yolov5。因此本博文利用YOLOv5检测算法实现一种高精度家禽猪识别检测模型,再搭配上Pyside6库写出界面系统,完成目标检测识别页面的开发。

sc1434404661的博客 5804

Vivado使用技巧(2):综合运行与OOC

创建综合运行 一个“运行(run)”是指定义和配置设计在综合过程中的各方面,包括:使用 的Xilinx器件、应用的约束集、启动单个或多个综合的选项、控制综合引擎结果的选项。点击Flow菜单中的Create Funs,或在Design Runs窗口中:  点击工具栏中的+,即可打开新建运行窗口:   选择Synthesis,点击Next,打开配置综合运行的窗口:  设置综合名称、...

bleauchat的博客 5617

从零到一:uniPush2.0全链路集成与多厂商通道配置实战

本文提供了uniPush2.0从零开始的全链路集成与多厂商通道配置实战指南。详细讲解了DCloud平台配置、uniCloud云函数开发、客户端CID获取与消息监听,并重点攻克了华为、小米、OPPO、vivo等主流厂商推送通道的配置难点与避坑技巧,帮助UniApp开发者实现“一次集成,全端覆盖”的高效消息推送方案。

onion的博客 436

华为OD机试 新系统 双机位C卷 往年真题 机考题库(持续收录中)以及算法考点详解(Python/JS/C/C++)

刷的越多,抽中的概率越大,每一题都有详细的答题思路、详细的代码注释发现新题目,随时更新。

学Java,找哪吒 5万+

Flume1.5.0入门:安装、部署、及flume的案例

问题导读 1.什么是flume 2.flume的官方网站在哪里? 3.flume有哪些术语? 4.如何配置flume数据源码?   一、什么是Flume?   flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应用。Flume 初始的发行版本目前被统称为 Flume OG(original generation),属于 cloudera。但随着

鲍礼彬的CSDN博客 ~_~ 1675

基于单片机的智能体重秤设计与嵌入式程序实现

智能体重秤的基本功能是测量用户的体重,并将数据通过无线方式传输到终端设备(如智能手机、电脑或云平台)进行管理。体重测量:实时测量用户体重,并进行数据存储。BMI(体质指数)计算:基于体重和身高计算BMI值,帮助用户了解健康状况。多用户管理:通过蓝牙或Wi-Fi技术支持多用户体重数据记录。健康数据分析:结合历史数据分析体重变化趋势。语音播报:通过语音播报用户体重,便于老人或视力不便的人士使用。数据同步:通过App或云平台同步数据,进行长期健康监控。

2201_76125393的博客 1758

Flume【部署 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证

Flume CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证

Java与大数据相关实践内容分享! 1285

在 SAP 中启用应收/应付“代扣税(Withholding Tax)”功能,本质上是激活并配置“扩展代扣税(Extended Withholding Tax)”模型

摘要:SAP中启用应收/应付代扣税功能需完成3个层级12个核心步骤:1)全局激活公司代码代扣税功能;2)配置代扣税规则、税率和科目,包括定义税种类型、代码、总账科目等;3)在供应商/客户主数据中关联代扣税设置。完成后系统可在发票或付款环节自动计算并过账代扣税,支持多税种并行计算和税率年度调整,最终生成税务报表。常见问题排查需检查公司代码激活状态和主数据配置。(149字)

金牌架构师 844

1 电科院FTU检测标准学习笔记-外观检查

作者简介:本人从事电力系统多年,岗位包含研发,测试,工程等,具有丰富的经验在配电自动化验收测试以及电科院测试中,本人全程参与,积累了不少现场的经验。

sixtome 1855

Flume1.9基础学习

Flume 是Cloudera 提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统。Flume 基于流式架构,灵活简单。Flume最主要的作用就是,实时读取服务器本地磁盘的数据(或者网络端口数据),将数据写入到HDFS使用 Flume 监听一个端口,收集该端口数据,并打印到控制台。

Shawn的个人博客 1539

DeepSeek:为文化创意产业注入AI新动能

沪南胜境,闵行新章。随后,2024 年 5 月,DeepSeek 宣布开源第二代 MoE 大模型 DeepSeek-V2,以其比肩 GPT-4Turbo 的卓越性能,以及仅为 GPT-4 百分之一的价格优势,迅速在市场中掀起波澜,收获了 “AI 届拼多多” 的独特名号,让更多人看到了高性价比 AI 大模型的可能性。创作者自身也应提高对创作伦理的认识,树立正确的创作观念,在使用 AI 工具时,保持对创作的主导权,充分发挥自己的创造力和想象力,将 AI 作为创作的辅助工具,而不是替代品。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1968

大数据学习——Flume入门

文章目录一、Flume概述1.1、Flume定义1.2、Flume基础架构二、Flume快速入门2.1、安装Flume部署2.2、入门案例2.2.1、监控端口数据(官方案例)Describe the sinkUse a channel which buffers events in memoryBind the source and sink to the channel2.2.2、实时监控单个追加文件2.2.3、监控文件 升级版2.2.4、监控文件夹变化2.2.5、断点续传——实时监控目录文件追加修改三、

5akura's Blog 3366

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Flume 从 0 到 1 学习 —— 第二章 Flume 快速入门

flume 安装、配置、自定义拦截器

dwjf321的博客 1121

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Flume学习5_Flume环境部署和配置详解及案例大全

flume是一个分布式、可靠、和高可用的海量日志采集、聚合和传输的系统。支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方(比如文本、HDFS、Hbase等)的能力 。 一、什么是Flume?   flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应用。Flume 初始的发行版本目前被统称为 Flu

wang_zhenwei的博客 954

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

大数据学习5之分布式日志收集框架Flume——Flume环境部署

Flume环境部署 Flume实战

level_Tiller的博客 295

Flume部署(详细版)

本文详细介绍了Flume 1.9.0的部署过程,包含7个关键步骤:1)从官网下载安装包;2)上传至虚拟机指定目录;3)解压并重命名安装目录;4)复制模板文件创建环境变量配置文件,添加JDK路径;5)配置系统环境变量;6)通过版本命令验证安装成功。文章采用图文结合的方式逐步讲解,适合初学者跟做,全文结构清晰,操作步骤详细。

djr0624的博客 840

Flume监控之Ganglia安装与简单实践

写在前面: 博主是一名大数据的初学者,昵称来源于《爱丽丝梦游仙境》中的Alice和自己的昵称。作为一名互联网小白,写博客一方面是为了记录自己的学习历程,一方面是希望能够帮助到很多和自己一样处于起步阶段的萌新。由于水平有限,博客中难免会有一些错误,有纰漏之处恳请各位大佬不吝赐教!个人小站:http://alices.ibilibili.xyz/ , 博客主页:https://alice.blog.csdn.net/ 尽管当前水平可能不及各位大佬,但我还是希望自己能够做得更好,因为一天的生活就是一生的缩影。.

大数据梦想家 3956

Flume安装部署 for Mac or Linux

最近学习到Flume,记录一下部署过程,以便后续使用 Flume官网http://flume.apache.org/ 我所使用的版本是flume-ng-1.6.0-cdh5.15.1 下载地址为http://archive.cloudera.com/cdh5/cdh/5/flume-ng-1.6.0-cdh5.15.1.tar.gz 1)前置条件 Java运行时环境-Jav...

近海_ 508

Hadoop学习笔记(27)Flume的简介以及安装部署

一、Flume的简介 Flume是Cloundera提供的一个高可用的、高可靠的、分布式的海量日志采集、聚合、传输的系统。Flume基于流式架构,灵活简单。 Flime最主要的作用是:实时读取服务器本地磁盘的数据,将数据写入到HDFS。 1、Flume基础架构 Flume基础组成架构如图: ...

boranyueshijie的博客 507

大数据技术学习笔记(十一)—— Flume

Flume 是 Cloudera 公司提供的一个高可用的,高可靠的,分布式的海量日志采集聚合和传输的系统。Flume 基于流式架构,灵活简单。这里的日志不是指框架工作运行的日志,而是跟业务相关的日志数据,如用户行为数据等Flume 最主要的作用就是,实时读取服务器本地磁盘的数据,将数据写入到 HDFS。案例需求。

hu_wei123的博客 1698

Flume学习笔记:Flume的安装与基础应用

Flume基础概念与应用

lrxcmwy2的博客 660

Flume学习日志

1.Flume概述 1.1Flume定义 Flume是Cloudera提供的一个 高可用的、高可靠的分布式的海量数据采集、聚合和传输的系统。Flume基于流式架构,灵活简单。(只读取日志文本文件) 1.2Flume基础架构 1.2.1 Agent ​ Agent 是一个 JVM 进程,它以事件的形式将数据从源头送至目的,是 Flume 数据传输的基本单元。 ​ Agent 主要有 3 个部分组成,Source、Channel、Sink。 1.2.2 Source ​ **Source 是负责接收数据到 Fl

weixin_44585687的博客 172

数据仓库 — 06_Flume的安装与部署(Flume组成框架、Agent内部原理、安装配置、日志采集配置文件、拦截器的编写、Flume群起脚本、Flume启动报错解决)

文章目录1 概述1.1 Flume定义1.2 Flume组成架构1.2.1 Agent1.2.2 Source1.2.3 Channel1.2.4 Sink1.2.5 Event1.3 Flume拓扑结构1.3.1 Agent连接1.3.2 单source多channel、sink1.3.3 负载均衡1.3.4 Agent聚合1.4 Flume Agent内部原理2 Flume的安装与配置2.1 下载地址2.2 安装部署3 项目经验——flume组件3.1 source3.2 channel4 日志采集的f

文泽路小男孩的博客 1586
上一篇: Spark学习1_【Spark六十一】Spark Streaming组合Flume、Kafka进行日志分析
下一篇: flume学习(一):log4j直接输出日志到flume
Wang_Zhenwei
博客等级 码龄11年 315粉丝 113原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址