First steps
#
第一步#
Welcome to Flink! :) 欢迎来到Flink!:)
Flink is designed to process continuous streams of data at a lightning fast pace. This short guide
will show you how to download the latest stable version of Flink, install, and run it. You will
also run an example Flink job and view it in the web UI.
Flink旨在以闪电般的速度处理连续的数据流。这个简短的指南将向您展示如何下载最新的Flink稳定版本,安装和运行它。您还将运行一个示例Flink作业并在Web UI中查看它。
Downloading Flink
#
下载Flink #
Note: Flink is also available as a Docker image.
注意:Flink也可以作为Docker镜像使用。
Flink runs on all UNIX-like environments, i.e. Linux, Mac OS X, and Cygwin (for Windows). You need
to have Java 11 installed. To check the Java version installed, type in your terminal:
Flink运行在所有类UNIX环境中,即Linux,Mac OS X和Cygwin(适用于Windows)。您需要安装Java 11。要检查安装的Java版本,请在终端中键入:
$ java -version
Next, download the latest binary release of Flink,
then extract the archive:
接下来,下载Flink的最新二进制版本,然后解压缩存档:
$ tar -xzf flink-*.tgz
Browsing the project directory
#
浏览项目目录#
Navigate to the extracted directory and list the contents by issuing:
导航到解压缩的目录,并通过发出以下命令列出内容:
$ cd flink-* && ls -l
You should see something like:
你应该看到类似这样的东西:

For now, you may want to note that:
现在,您可能需要注意:
- bin/ directory contains the
flink
binary as well as several bash scripts that manage various jobs and tasks
bin/目录包含flink
二进制文件以及几个管理各种作业和任务的bash脚本 - conf/ directory contains configuration files, including
flink-conf.yaml
conf/目录包含配置文件,包括flink-conf.yaml
- examples/ directory contains sample applications that can be used as is with Flink
examples/目录包含可以与Flink一起使用的示例应用程序
Starting and stopping a local cluster
#
启动和停止本地群集#
To start a local cluster, run the bash script that comes with Flink:
要启动本地集群,请运行Flink附带的bash脚本:
$ ./bin/start-cluster.sh
You should see an output like this:
你应该看到这样的输出:

Flink is now running as a background process. You can check its status with the following command:
Flink现在作为后台进程运行。您可以使用以下命令检查其状态:
$ ps aux | grep flink
You should be able to navigate to the web UI at localhost:8081 to view
the Flink dashboard and see that the cluster is up and running.
您应该能够导航到localhost:8081的Web UI以查看Flink仪表板并查看集群是否已启动并运行。
To quickly stop the cluster and all running components, you can use the provided script:
要快速停止群集和所有正在运行的组件,您可以使用提供的脚本:
$ ./bin/stop-cluster.sh
Submitting a Flink job
#
提交Flink作业#
Flink provides a CLI tool, bin/flink, that can run programs packaged as Java ARchives (JAR)
and control their execution. Submitting a job means uploading the job’s JAR file and related dependencies to the running Flink cluster
and executing it.
Flink提供了一个CLI工具bin/flink,它可以运行打包为Java ARchives(Java ARchives)的程序并控制它们的执行。提交作业意味着将作业的文件和相关依赖项上传到正在运行的Flink集群并执行它。
Flink releases come with example jobs, which you can find in the examples/ folder.
Flink版本附带了示例作业,您可以在examples/文件夹中找到。
To deploy the example word count job to the running cluster, issue the following command:
要将示例字数统计作业部署到正在运行的群集,请发出以下命令:
$ ./bin/flink run examples/streaming/WordCount.jar
You can verify the output by viewing the logs:
您可以通过查看日志来验证输出:
$ tail log/flink-*-taskexecutor-*.out
Sample output: 输出示例:
(nymph,1)
(in,3)
(thy,1)
(orisons,1)
(be,4)
(all,2)
(my,1)
(sins,1)
(remember,1)
(d,4)
Additionally, you can check Flink’s web UI to monitor the status of the cluster and running job.
此外,您可以检查Flink的Web UI以监控集群和运行作业的状态。
You can view the data flow plan for the execution:
您可以查看执行的数据流计划:

Here for the job execution, Flink has two operators. The first is the source operator which reads data from the
collection source. The second operator is the transformation operator which aggregates counts of words. Learn
more about DataStream operators.
在这里,对于作业执行,Flink有两个操作员。第一个是源操作符,它从集合源读取数据。第二个操作符是转换操作符,它聚集单词的计数。了解有关DataStream运算符的更多信息。
You can also look at the timeline of the job execution:
您还可以查看作业执行的时间轴:

You have successfully ran a Flink application! Feel free to select any other JAR archive from the examples/
folder or deploy your own job!
您已成功运行Flink应用程序!请随意从examples/文件夹中选择任何其他的JavaScript归档文件或部署您自己的作业!
Summary # 摘要编号
In this guide, you downloaded Flink, explored the project directory, started and stopped a local cluster, and submitted a sample Flink job!
在本指南中,您下载了Flink,浏览了项目目录,启动和停止了本地集群,并提交了一个示例Flink作业!
To learn more about Flink fundamentals, check out the concepts section. If you want to try something more hands-on, try one of the tutorials.
要了解更多关于Flink基础知识的信息,请查看概念部分。如果你想尝试更多的动手操作,尝试教程之一。