Flume(1)使用入门

1、概述:

Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统。html

当前Flume有两个版本Flume 0.9X版本的统称Flume-og,Flume1.X版本的统称Flume-ng。因为Flume-ng通过重大重构,与Flume-og有很大不一样,使用时请注意区分。node

先来看几张数据流图:apache

image

image

image

从上面的图大体能够知道,flume就是将source数据导入到输出中的一个工具。source能够有多个,输出也能够有多个。并发

2、环境说明:

本文中使用的flume是1.6.0版本。分布式

3、环境搭建:(一个简单的示例)

一、首先从官网上下载对应的二进制tar包。http://flume.apache.org/download.html工具

二、解压文件,并拷贝到指定目录下。this

tar -zxvf apache-flume-1.6.0-bin.tar.gz

三、在flume的安装目录下的conf目录中建立一个配置文件test.conf:spa

# example.conf: A single-node Flume configuration

# 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

该配置文件监听了44444端口。命令行

四、启动flume的agent:3d

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

执行完上述命令,命令行就会处于监听状态。会将该端口监听到的数据直接打印到命令行窗口中。

上面的a1,指的就是配置文件test.conf中定义的a1.

image

五、经过telnet链接,并发送信息。

因为配置文件中使用的localhost,因此咱们在本机重开一个命令行窗口。

telnet localhost 44444

咱们在telnet命令行键入如下内容:

image

在flume的命令行就能够看到监听到的数据:

image

至此,flume安装完毕并演示了一个简单的示例。

相关文章
相关标签/搜索