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安裝完畢並演示了一個簡單的示例。

相關文章
相關標籤/搜索