Apache Flume 简明教程
Apache Flume - Environment
我们已经在上一章讨论了 Flume 的架构。在本章中,让我们看看如何下载并设置 Apache Flume。
We already discussed the architecture of Flume in the previous chapter. In this chapter, let us see how to download and setup Apache Flume.
在继续进行之前,您的系统中必须有 Java 环境。所以首先,确保您已经在系统中安装了 Java。在本教程的一些示例中,我们使用了 Hadoop HDFS(作为接收方)。因此,我们建议您安装 Hadoop 以及 Java。要收集更多信息,请访问链接 https://www.tutorialspoint.com/hadoop/hadoop_enviornment_setup.htm
Before proceeding further, you need to have a Java environment in your system. So first of all, make sure you have Java installed in your system. For some examples in this tutorial, we have used Hadoop HDFS (as sink). Therefore, we would recommend that you go install Hadoop along with Java. To collect more information, follow the link − https://www.tutorialspoint.com/hadoop/hadoop_enviornment_setup.htm
Installing Flume
首先,从网站 https://flume.apache.org/ 下载最新版本的 Apache Flume 软件。
First of all, download the latest version of Apache Flume software from the website https://flume.apache.org/.
Step 1
打开该网站。点击主页左侧的 download 链接。它将带您到 Apache Flume 的下载页面。
Open the website. Click on the download link on the left-hand side of the home page. It will take you to the download page of Apache Flume.

Step 2
在“下载”页面中,您可以看到 Apache Flume 的二进制文件和源文件的链接。点击 apache-flume-1.6.0-bin.tar.gz 链接
In the Download page, you can see the links for binary and source files of Apache Flume. Click on the link apache-flume-1.6.0-bin.tar.gz
您将被重新定向到一个镜像列表,您可以通过点击其中任何一个镜像开始下载。同样,您可以通过点击 apache-flume-1.6.0-src.tar.gz 下载 Apache Flume 的源代码。
You will be redirected to a list of mirrors where you can start your download by clicking any of these mirrors. In the same way, you can download the source code of Apache Flume by clicking on apache-flume-1.6.0-src.tar.gz.
Step 3
在安装 Hadoop 、 HBase 和其他软件的安装目录所在的同一个目录中创建一个名为 Flume 的目录(如果您已经安装了任何软件),如下所示。
Create a directory with the name Flume in the same directory where the installation directories of Hadoop, HBase, and other software were installed (if you have already installed any) as shown below.
$ mkdir Flume
Step 4
解压已下载的 tar 文件,如下所示。
Extract the downloaded tar files as shown below.
$ cd Downloads/
$ tar zxvf apache-flume-1.6.0-bin.tar.gz
$ tar zxvf apache-flume-1.6.0-src.tar.gz
Step 5
将 apache- flume-1.6.0-bin.tar 文件的内容移动到前面创建的 Flume 目录中,如下所示。(假设我们在名为 Hadoop 的本地用户中创建了 Flume 目录。)
Move the content of apache-flume-1.6.0-bin.tar file to the Flume directory created earlier as shown below. (Assume we have created the Flume directory in the local user named Hadoop.)
$ mv apache-flume-1.6.0-bin.tar/* /home/Hadoop/Flume/
Configuring Flume
若要配置 Flume,我们必须修改三个文件,即 flume-env.sh, flumeconf.properties, 和 bash.rc 。
To configure Flume, we have to modify three files namely, flume-env.sh, flumeconf.properties, and bash.rc.
Setting the Path / Classpath
在 .bashrc 文件中,为 Flume 设置主页文件夹、路径和类路径,如下所示。
In the .bashrc file, set the home folder, the path, and the classpath for Flume as shown below.

conf Folder
如果你打开 Apache Flume 的 conf ,你将有以下四个文件 −
If you open the conf folder of Apache Flume, you will have the following four files −
-
flume-conf.properties.template,
-
flume-env.sh.template,
-
flume-env.ps1.template, and
-
log4j.properties.

现在将
Now rename
-
flume-conf.properties.template file as flume-conf.properties and
-
flume-env.sh.template as flume-env.sh
Verifying the Installation
通过浏览 bin 文件夹并输入以下命令,确认 Apache Flume 的安装。
Verify the installation of Apache Flume by browsing through the bin folder and typing the following command.
$ ./flume-ng
如果你已经成功安装 Flume,你将得到一个如图所示的 Flume 帮助提示。
If you have successfully installed Flume, you will get a help prompt of Flume as shown below.
