【学会了学会了】Flink官网翻译——踏出第一步(First Steps)

前言

从2021年开始的2022年Flink官网翻译计划,希望能给你带来帮助!

踏出第一步(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,同时我们提供了一个样例程序,你可以运行和在Web界面查看它。

下载Flink(Download 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 8 or 11 installed. To check the Java version installed, type in your terminal:

Flink可运行在所有的类-Unix环境中,包括Linux、Mac OS X以及Windows。
前提条件:Java8或Java11及以上版本,在终端运行如下命令,检查Java环境:

java -version

Next, download the latest binary release of Flink, then extract the archive:

Java环境正常后,下载Flink最新稳定包,然后解压:

tar -xvf 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
conf/ directory contains configuration files, including flink-conf.yaml
examples/ directory contains sample applications that can be used as is with Flink

你需要关注如下几个目录:

  • bin/目录:包含了flink二进制文件以及多个用于管理作业和任务的bash文件
  • conf/目录:包含flink的配置文件,如“flink-conf.yaml”
  • examples/目录:包含了Flink样例应用

启动和停止本地集群(Starting and stopping a local cluster)

To start a local cluster, run the bash script that comes with Flink:

运行Shell脚本以启动Flink本地集群:

./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作为后台进程运行后,可通过如下命令检查其状态:

pa 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.

你可以通过WebUI界面查看Flink驾驶舱,可以看到集群已启动正在运行。

To quickly stop the cluster and all running components, you can use the provided script:

使用如下命令,快速停止集群和所有运行中的组件

./bin/stop-cluster.sh

提交Flink任务(Submitting a Flink job)

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提供了一个客户端命令,bin/flink,该命令可以运行Java Jar包,并控制程序的执行。提交一个作业意味着上传作业Jar包及相关依赖到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:

通过如下命令,提交单词计数作业到Flink集群:

./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.

此外,你可以查看Fliink 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执行了两种操作。

  • Source:从数据源读取数据
  • Transformation:对单词进行聚合统计

更多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/目录的其他样例程序或者运行你自己的作业吧!

总结

以上就是Flink入门的第一步,有更多问题可以私信我一起交流学习!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值