flume简介

来源:互联网 发布:55开和淘宝权怎么了 编辑:程序博客网 时间:2024/05/08 06:36

flume是一个分布式、可靠和高可用的服务,用于收集、聚合以及移动大量日志数据。
flume分为Source组件、Channel组件、Sink组件。
这里写图片描述
Source组件负责日志流入,比如从文件、网络、kafka等数据源流入数据,数据流入的方式有两种:轮训拉取和事件驱动;
Channel组件负责数据聚合/暂存,比如暂存到内存、本地文件、数据库、kafka等,日志数据不会再管道停留很长时间,很快会被Sink消费掉;
Sink组件负责数据转移存储,比如从Channel拿到日志后直接存储到HDFS、HBase、kafka、ElasticSearch等。

flume服务的搭建需要以下软件环境:

  • linux服务器一台或多台
  • JDK
  • apache-flume-1.6.0-bin.tar.gz

linux配置JDK可以参考CentOS 7安装配置JDK
apache-flume-1.6.0-bin.tar.gz下载地址:apache-flume-1.6.0-bin.tar.gz
下载完成后,我们把apache-flume-1.6.0-bin.tar.gz上传到/usr/local/flume目录,运行tar -zxvf apache-flume-1.6.0-bin.tar.gz解压tar文件,运行

cp flume-env.sh.template flume-env.shcp flume-conf.properties.template flume-conf.properties

复制flume-env.sh和flume-conf.properties文件。
配置flume-env.sh

vim flume-env.shexport JAVA_HOME=/usr/local/java/jdk1.8.0_40

配置flume-conf.properties
注释flume-conf.properties的全部内容,添加如下配置:

a1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = netcata1.sources.r1.bind = localhosta1.sources.r1.port = 44444# Describe the sinka1.sinks.k1.type = logger# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

启动服务

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

另起一个终端,运行telnet localhost 44444可以测试发送消息是否成功。
更多关于flume的操作,可以参考Flume API。

0 0