提交 2464c5b4 编写于 作者: L liuchong

翻译完成

上级 58246af3
此差异已折叠。
# Standalone Cluster
# 独立集群
This page provides instructions on how to run Flink in a _fully distributed fashion_ on a _static_ (but possibly heterogeneous) cluster.
这里给出如何在集群上以完全分布式方式运行Flink程序的说明 .
## Requirements
## 需求
### Software Requirements
### 软件需求
Flink runs on all _UNIX-like environments_, e.g. **Linux**, **Mac OS X**, and **Cygwin** (for Windows) and expects the cluster to consist of **one master node** and **one or more worker nodes**. Before you start to setup the system, make sure you have the following software installed **on each node**:
Flink 需要运行在类unix环境下,比如 **Linux**, **Mac OS X**, 和 **Cygwin** (适用于Windows) 希望集群中至少由一个**主节点**和最少一个**工作节点**组成。 在开始运行前,需要保证 **每个节点**上都安装了一下软件:
* **Java 1.8.x** or higher,
* **ssh** (sshd must be running to use the Flink scripts that manage remote components)
* **Java 1.8.x** 及其以上版本,
* **ssh** (必须运行sshd才能使用管理远程组件的Flink脚本)
If your cluster does not fulfill these software requirements you will need to install/upgrade it.
如果您的群集不满足这些软件要求,则需要安装/升级软件来达到要求.
Having **passwordless SSH** and **the same directory structure** on all your cluster nodes will allow you to use our scripts to control everything.
通过 **SSH互信****相同的目录结构** 这样我们的脚本就能控制所有内容.
### `JAVA_HOME` Configuration
### `JAVA_HOME` 配置
Flink requires the `JAVA_HOME` environment variable to be set on the master and all worker nodes and point to the directory of your Java installation.
Flink程序要求所有节点上必须设置`JAVA_HOME`环境变量,并`JAVA_HOME`环境变量指向JAVA的安装目录.
You can set this variable in `conf/flink-conf.yaml` via the `env.java.home` key.
可以通过 `conf/flink-conf.yaml` 文件中的 `env.java.home` 配置来设置配置.
## Flink Setup
Go to the [downloads page](http://flink.apache.org/downloads.html) and get the ready-to-run package. Make sure to pick the Flink package **matching your Hadoop version**. If you don’t plan to use Hadoop, pick any version.
After downloading the latest release, copy the archive to your master node and extract it:
## Flink 安装
转到 [下载页](http://flink.apache.org/downloads.html) 下载Flink安装程序. 程序中如果需要使用Hadoop,则选择的Flink版本要保证和 **Hadoop 版本**相匹配。否则可以选择任何版本
下载完毕后,复制到主节点并解压:
```
tar xzf flink-*.tgz
......@@ -38,17 +36,17 @@ cd flink-*
### Configuring Flink
### 配置 Flink
After having extracted the system files, you need to configure Flink for the cluster by editing _conf/flink-conf.yaml_.
解压缩之后,需要修改Flink的配置文件,配置文件名称为 _conf/flink-conf.yaml_。
Set the `jobmanager.rpc.address` key to point to your master node. You should also define the maximum amount of main memory the JVM is allowed to allocate on each node by setting the `jobmanager.heap.mb` and `taskmanager.heap.mb` keys.
修改 `jobmanager.rpc.address` 配置值为主节点,设置 `jobmanager.heap.mb``taskmanager.heap.mb` 用来指定JVM在每个节点上分配的最大堆内存量。
These values are given in MB. If some worker nodes have more main memory which you want to allocate to the Flink system you can overwrite the default value by setting the environment variable `FLINK_TM_HEAP` on those specific nodes.
这些设置值单位为 MB. 如果某工作节点有更多主内存可以分配给Flink系统,可以修改节点上的 `FLINK_TM_HEAP` 配置来覆盖默认值。
Finally, you must provide a list of all nodes in your cluster which shall be used as worker nodes. Therefore, similar to the HDFS configuration, edit the file _conf/slaves_ and enter the IP/host name of each worker node. Each worker node will later run a TaskManager.
最后,必须提供集群中所有节点的列表,这些节点将用作工作节点。与HDFS配置类似, 编辑_conf/slaves_文件,并输入每个工作节点的IP /主机名. 每个工作节点将运行 _TaskManager_.
The following example illustrates the setup with three nodes (with IP addresses from _10.0.0.1_ to _10.0.0.3_ and hostnames _master_, _worker1_, _worker2_) and shows the contents of the configuration files (which need to be accessible at the same path on all machines):
下图说明了具有三个节点 (IP 地址 从_10.0.0.1_ 到 _10.0.0.3_ 和对应的主机名 _master_, _worker1_, _worker2_)的集群配置, 并显示了配置文件的内容(需要在所有计算机上的相同路径上访问)):
![](../img/quickstart_cluster.png)
......@@ -67,27 +65,25 @@ conf/slaves**
10.0.0.3
```
The Flink directory must be available on every worker under the same path. You can use a shared NFS directory, or copy the entire Flink directory to every worker node.
Please see the [configuration page](../config.html) for details and additional configuration options.
In particular,
Flink目录必须每个worker上同一路径下都可用。可以使用共享NFS目录,也可以将整个Flink目录复制到每个工作节点。
* the amount of available memory per JobManager (`jobmanager.heap.mb`),
* the amount of available memory per TaskManager (`taskmanager.heap.mb`),
* the number of available CPUs per machine (`taskmanager.numberOfTaskSlots`),
* the total number of CPUs in the cluster (`parallelism.default`) and
* the temporary directories (`taskmanager.tmp.dirs`)
有关详细信息和其他配置选项,请参阅 [configuration page](../config.html)
are very important configuration values.
需要额外注意的一些配置是,
### Starting Flink
* 每个JobManager的可用内存总量 (`jobmanager.heap.mb`),
* 每个TaskManager的可用内容总量 (`taskmanager.heap.mb`),
* 每台机器的可用CPU数量 (`taskmanager.numberOfTaskSlots`),
* 集群中的CPU总数 (`parallelism.default`)
* 临时目录 (`taskmanager.tmp.dirs`)
The following script starts a JobManager on the local node and connects via SSH to all worker nodes listed in the _slaves_ file to start the TaskManager on each node. Now your Flink system is up and running. The JobManager running on the local node will now accept jobs at the configured RPC port.
这些是对Flink非常重要的配置值。
Assuming that you are on the master node and inside the Flink directory:
### 启动Flink
以下脚本在本地节点上启动JobManager,并通过ssh连接到所有_slaves_文件中定义的所有工作节点,启动TaskManger。 现在Flink系统已启动并正在运行。 在本地运行的JobManager 将通过配置的RPC端口来接受作业提交。
A假设您在主节点上并在Flink目录中:
```
bin/start-cluster.sh
......@@ -95,13 +91,13 @@ bin/start-cluster.sh
To stop Flink, there is also a `stop-cluster.sh` script.
停止Flink对应的脚本是 `stop-cluster.sh`
### Adding JobManager/TaskManager Instances to a Cluster
### 将JobManager/TaskManager实例添加到群集
You can add both JobManager and TaskManager instances to your running cluster with the `bin/jobmanager.sh` and `bin/taskmanager.sh` scripts.
可以使用 `bin/jobmanager.sh``bin/taskmanager.sh` 脚本将JobManager和TaskManager实例添加到正在运行的集群中.
#### Adding a JobManager
#### 添加 JobManager
......@@ -111,7 +107,7 @@ bin/jobmanager.sh ((start|start-foreground) [host] [webui-port])|stop|stop-all
#### Adding a TaskManager
#### 添加 TaskManager
......@@ -121,5 +117,5 @@ bin/taskmanager.sh start|start-foreground|stop|stop-all
Make sure to call these scripts on the hosts on which you want to start/stop the respective instance.
需要保证在对应的机器上调用启动/停止脚本。
此差异已折叠。
# Mesos Setup
# Mesos 设置
## Background
## 背景
The Mesos implementation consists of two components: The Application Master and the Worker. The workers are simple TaskManagers which are parameterized by the environment set up by the application master. The most sophisticated component of the Mesos implementation is the application master. The application master currently hosts the following components:
Mesos实现包含两个组件:Application Master和Worker。Worker是简单的TaskManagers,由应用程序设置的环境进行参数化。Mesos实现中最复杂的组件是应用程序主机。应用程序主机当前托管以下组件:
### Mesos Scheduler
### Mesos 调度程序
The scheduler is responsible for registering the framework with Mesos, requesting resources, and launching worker nodes. The scheduler continuously needs to report back to Mesos to ensure the framework is in a healthy state. To verify the health of the cluster, the scheduler monitors the spawned workers and marks them as failed and restarts them if necessary.
调度程序负责向Mesos注册,请求资源和启动工作节点。调度程序不断向Mesos报告以确保框架处于正常状态。为了验证群集的运行状况,调度程序监视生成的worker并将其标记为失败,并在必要时重新启动它们。
Flink’s Mesos scheduler itself is currently not highly available. However, it persists all necessary information about its state (e.g. configuration, list of workers) in Zookeeper. In the presence of a failure, it relies on an external system to bring up a new scheduler. The scheduler will then register with Mesos again and go through the reconciliation phase. In the reconciliation phase, the scheduler receives a list of running workers nodes. It matches these against the recovered information from Zookeeper and makes sure to bring back the cluster in the state before the failure.
Flink的Mesos调度程序本身目前不具备高可用性。但是,它会在Zookeeper中保存有关其状态(例如配置,工作者列表)的所有必要信息。在出现故障时,它依赖于外部系统来启动新的调度程序。然后,调度程序将再次向Mesos注册并完成协调阶段。在协调阶段,调度程序接收正在运行的工作程序节点的列表。它将这些与Zookeeper中恢复的信息进行匹配,并确保在故障之前将群集恢复到状态。
### Artifact Server
### 工作服务器
The artifact server is responsible for providing resources to the worker nodes. The resources can be anything from the Flink binaries to shared secrets or configuration files. For instance, in non-containerized environments, the artifact server will provide the Flink binaries. What files will be served depends on the configuration overlay used.
工件服务器负责向工作节点提供资源。资源可以是从Flink二进制文件或者是配置文件。例如,在非容器化环境中,工件服务器将提供Flink二进制文件和需要依赖的文件。
### Flink’s Dispatcher and Web Interface
### Flink’s 的调度程序和web页面
The Dispatcher and the web interface provide a central point for monitoring, job submission, and other client interaction with the cluster (see [FLIP-6](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=65147077)).
Flink提供了Web界面为监视,为作业提交和监控交互提供了便利(参阅 [FLIP-6](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=65147077)).
### Startup script and configuration overlays
### 启动脚本和配置覆盖
The startup script provide a way to configure and start the application master. All further configuration is then inherited by the workers nodes. This is achieved using configuration overlays. Configuration overlays provide a way to infer configuration from environment variables and config files which are shipped to the worker nodes.
启动脚本提供了一种配置和启动应用程序主机的方法。然后,工作节点继承所有的配置。这是使用配置覆盖来实现的。配置覆盖提供了一种从环境变量和配置文件推断配置的方法,这些配置文件将发送到工作节点。
## DC/OS
This section refers to [DC/OS](https://dcos.io) which is a Mesos distribution with a sophisticated application management layer. It comes pre-installed with Marathon, a service to supervise applications and maintain their state in case of failures.
本文涉及到 [DC/OS](https://dcos.io) 它是具有复杂应用程序管理层的Mesos分发。它预装了Marathon,这是一种监控应用程序并在发生故障时保持其状态的服务。
If you don’t have a running DC/OS cluster, please follow the [instructions on how to install DC/OS on the official website](https://dcos.io/install/).
如果没有正在运行的DC/OS集群,可以参考 [如何安装DC/OS](https://dcos.io/install/).
Once you have a DC/OS cluster, you may install Flink through the DC/OS Universe. In the search prompt, just search for Flink. Alternatively, you can use the DC/OS CLI:
安装DC / OS群集后,可以通过DC / OS Universe安装Flink。在搜索提示中,只需搜索Flink。或者,可以使用DC / OS CLI:
```
dcos package install flink
```
Further information can be found in the [DC/OS examples documentation](https://github.com/dcos/examples/tree/master/1.8/flink).
详细信息请参阅 [DC/OS 示例](https://github.com/dcos/examples/tree/master/1.8/flink).
## Mesos without DC/OS
## 无 DC/OS的Mesos
You can also run Mesos without DC/OS.
也没在没有DC/OS的环境中运行 Mesos。
### Installing Mesos
### 安装 Mesos
Please follow the [instructions on how to setup Mesos on the official website](http://mesos.apache.org/getting-started/).
参阅 [MEsos安装指南](http://mesos.apache.org/getting-started/)来完成安装。
After installation you have to configure the set of master and agent nodes by creating the files `MESOS_HOME/etc/mesos/masters` and `MESOS_HOME/etc/mesos/slaves`. These files contain in each row a single hostname on which the respective component will be started (assuming SSH access to these nodes).
安装完成后,需要创建 `MESOS_HOME/etc/mesos/masters``MESOS_HOME/etc/mesos/slaves`文件来配置主机诶单和从节点。文件中每行包含一个主机名(要求可以通过ssh访问到这些节点)。
Next you have to create `MESOS_HOME/etc/mesos/mesos-master-env.sh` or use the template found in the same directory. In this file, you have to define
接下来需要创建 `MESOS_HOME/etc/mesos/mesos-master-env.sh` 文件,或者在同目录下找到模板,修改模板内容。以下内容是必须的
```
export MESOS_work_dir=WORK_DIRECTORY
```
and it is recommended to uncommment
并建议取消注释
```
export MESOS_log_dir=LOGGING_DIRECTORY
```
In order to configure the Mesos agents, you have to create `MESOS_HOME/etc/mesos/mesos-agent-env.sh` or use the template found in the same directory. You have to configure
配置Mesos代理,需要创建 `MESOS_HOME/etc/mesos/mesos-agent-env.sh` 文件,或在同目录下修改模板。
```
export MESOS_master=MASTER_HOSTNAME:MASTER_PORT
```
and uncomment
并取消注释
```
export MESOS_log_dir=LOGGING_DIRECTORY
export MESOS_work_dir=WORK_DIRECTORY
```
#### Mesos Library
#### Mesos 类库
In order to run Java applications with Mesos you have to export `MESOS_NATIVE_JAVA_LIBRARY=MESOS_HOME/lib/libmesos.so` on Linux. Under Mac OS X you have to export `MESOS_NATIVE_JAVA_LIBRARY=MESOS_HOME/lib/libmesos.dylib`.
#### Deploying Mesos
In order to start your mesos cluster, use the deployment script `MESOS_HOME/sbin/mesos-start-cluster.sh`. In order to stop your mesos cluster, use the deployment script `MESOS_HOME/sbin/mesos-stop-cluster.sh`. More information about the deployment scripts can be found [here](http://mesos.apache.org/documentation/latest/deploy-scripts/).
要使用Mesos运行Java应用程序, 请使用脚本 `MESOS_HOME/sbin/mesos-start-cluster.sh`. 停止Mesost则执行 `MESOS_HOME/sbin/mesos-stop-cluster.sh`. 更多关于部署脚本可以参阅[部署脚本](http://mesos.apache.org/documentation/latest/deploy-scripts/).
### Installing Marathon
### 安装 Marathon
Optionally, you may also [install Marathon](https://mesosphere.github.io/marathon/docs/) which enables you to run Flink in [high availability (HA) mode](#high-availability).
或者可以安装Marathon参阅 [Marathon安装](https://mesosphere.github.io/marathon/docs/) 即可开启高可用,参阅 [高可用模式](#high-availability).
### Pre-installing Flink vs Docker/Mesos containers
### 预安装Flink 与 Docker/Mesos 容器
You may install Flink on all of your Mesos Master and Agent nodes. You can also pull the binaries from the Flink web site during deployment and apply your custom configuration before launching the application master. A more convenient and easier to maintain approach is to use Docker containers to manage the Flink binaries and configuration.
可以在所有Mesos主节点和代理节点上安装Flink。或者在部署期间从Flink网站拉取二进制文件,并在启动应用程序主服务器之前应用自定义配置。使用Docker容器来管理Flink二进制文件和配置会是个更方便,更易于维护的方法。
This is controlled via the following configuration entries:
通过以下配置控制的:
```
mesos.resourcemanager.tasks.container.type: mesos _or_ docker
```
If set to ‘docker’, specify the image name:
如果设置为 `docker`,需要指定镜像名称
```
mesos.resourcemanager.tasks.container.image.name: image_name
......@@ -103,19 +103,19 @@ mesos.resourcemanager.tasks.container.image.name: image_name
### Standalone
In the `/bin` directory of the Flink distribution, you find two startup scripts which manage the Flink processes in a Mesos cluster:
Flink的 `/bin` 目录下可以找到两个脚本用来管理Mesos集群中的Flink进程
1. `mesos-appmaster.sh` This starts the Mesos application master which will register the Mesos scheduler. It is also responsible for starting up the worker nodes.
1. `mesos-appmaster.sh` 启动Mesos master,负责注册Mesos调度程序,还负责启动工作节点。
2. `mesos-taskmanager.sh` The entry point for the Mesos worker processes. You don’t need to explicitly execute this script. It is automatically launched by the Mesos worker node to bring up a new TaskManager.
2. `mesos-taskmanager.sh` Mesos工作进程的入口点。不需要执行此脚本。它由Mesos工作节点自动启动以启动新的TaskManager。
In order to run the `mesos-appmaster.sh` script you have to define `mesos.master` in the `flink-conf.yaml` or pass it via `-Dmesos.master=...` to the Java process.
执行 `mesos-appmaster.sh` 脚本需要在`flink-conf.yaml`中定义 `mesos.master`或者通过 `-Dmesos.master=…` 传递给Java进程
When executing `mesos-appmaster.sh`, it will create a job manager on the machine where you executed the script. In contrast to that, the task managers will be run as Mesos tasks in the Mesos cluster.
执行`mesos-appmaster.sh`时,它将在执行脚本的机器上创建一个JobManager。TaskManager将作为Mesos集群中的Mesos任务运行。
#### General configuration
#### 基本配置
It is possible to completely parameterize a Mesos application through Java properties passed to the Mesos application master. This also allows to specify general Flink configuration parameters. For example:
可以通过传递给Mesos应用程序主机的Java属性完全参数化Mesos应用程序。还允许指定常规Flink配置参数。例如
```
bin/mesos-appmaster.sh \
......@@ -129,17 +129,17 @@ bin/mesos-appmaster.sh \
-Dparallelism.default=10
```
**Note:** If Flink is in [legacy mode](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#legacy), you should additionally define the number of task managers that are started by Mesos via [`mesos.initial-tasks`](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#mesos-initial-tasks).
**Note:** 如果Flink处于 [legacy mode](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#legacy), 还需要定义TaskManager数量 参阅[`mesos.initial-tasks`](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#mesos-initial-tasks).
### High Availability
### 高可用
You will need to run a service like Marathon or Apache Aurora which takes care of restarting the Flink master process in case of node or process failures. In addition, Zookeeper needs to be configured like described in the [High Availability section of the Flink docs](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/jobmanager_high_availability.html).
还需要运行Marathon或Apache Aurora之类的服务,来确保节点或进程出现故障时重新启动Flink主进程。此外还需要一些额外的Zookeeper配置,参阅 [Flink 文档-高可用](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/jobmanager_high_availability.html).
#### Marathon
Marathon needs to be set up to launch the `bin/mesos-appmaster.sh` script. In particular, it should also adjust any configuration parameters for the Flink cluster.
执行 `bin/mesos-appmaster.sh` 脚本来启动Marathon,文件内还包含了一些Flink集群的配置参数。
Here is an example configuration for Marathon:
以下是Marathon的示例配置:
```
{
......@@ -150,9 +150,9 @@ Here is an example configuration for Marathon:
}
```
When running Flink with Marathon, the whole Flink cluster including the job manager will be run as Mesos tasks in the Mesos cluster.
使用Marathon运行Flink时,包含JobManager的整个Flink集群将作为Mesos集群中的Mesos任务运行。
### Configuration parameters
### 配置参数
For a list of Mesos specific configuration, refer to the [Mesos section](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#mesos) of the configuration documentation.
有关Mesos特定配置的列表,请参阅 [Mesos配置](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#mesos)
# Docker Setup
# Docker安装
[Docker](https://www.docker.com) is a popular container runtime. There are Docker images for Apache Flink available on Docker Hub which can be used to deploy a session cluster. The Flink repository also contains tooling to create container images to deploy a job cluster.
[Docker](https://www.docker.com) 是一个流行的运行时容器。 Docker Hub上有用于Apache Flink的Docker镜像,可用于部署Flink群集。Flink源还有用于部署作业集群的镜像。
## Flink session cluster
## Flink集群
A Flink session cluster can be used to run multiple jobs. Each job needs to be submitted to the cluster after it has been deployed.
Flink群集可用于运行多个作业。部署后,多个作业可逐个提交到集群。
### Docker images
### Docker 镜像
The [Flink Docker repository](https://hub.docker.com/_/flink/) is hosted on Docker Hub and serves images of Flink version 1.2.1 and later.
[Flink Docker repository](https://hub.docker.com/_/flink/) 是Flink托管在 Docker Hub上的地址,提供了Flink1.2.1版本以上的镜像。
Images for each supported combination of Hadoop and Scala are available, and tag aliases are provided for convenience.
镜像支持Hadoop和scala的环境组合,为了方便通tag别名来区分。
Beginning with Flink 1.5, image tags that omit a Hadoop version (e.g. `-hadoop28`) correspond to Hadoop-free releases of Flink that do not include a bundled Hadoop distribution.
从Flink 1.5版本以后, 镜像tags省略了Hadoop版本 (例如 `-hadoop28`) 对应于不包含Hadoop发行版的Flink的无Hadoop版本。
For example, the following aliases can be used: _(`1.5.y` indicates the latest release of Flink 1.5)_
举例,下面的别名可以使用: _(`1.5.y` 表示Flink 1.5的最新版本)_
* `flink:latest``flink:<latest-flink>-scala_<latest-scala>`
* `flink:1.5``flink:1.5.y-scala_2.11`
* `flink:1.5-hadoop27``flink:1.5.y-hadoop27-scala_2.11`
**Note:** The Docker images are provided as a community project by individuals on a best-effort basis. They are not official releases by the Apache Flink PMC.
**注意:** Docker镜像是由个人方式提供的社区项目。不是Apache Flink PMC的正式版本。
## Flink job cluster
## Flink作业集群
A Flink job cluster is a dedicated cluster which runs a single job. The job is part of the image and, thus, there is no extra job submission needed.
Flink作业集群是运行单个作业的专用集群。这项是镜像内容的一部分,不需要额外的操作。
### Docker images
### Docker 镜像
The Flink job cluster image needs to contain the user code jars of the job for which the cluster is started. Therefore, one needs to build a dedicated container image for every job. The `flink-container` module contains a `build.sh` script which can be used to create such an image. Please see the [instructions](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/README.md) for more details.
Flink作业集群镜像需要包含用户代码jar。因此,需要为每个作业单独构建镜像。 `flink-container` 模块包含了一个 `build.sh` 脚本,用于创建此类镜像,详情可参阅 [instructions](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/README.md)
## Flink with Docker Compose
## Flink Docker Compose
[Docker Compose](https://docs.docker.com/compose/) is a convenient way to run a group of Docker containers locally.
[Docker Compose](https://docs.docker.com/compose/) 是一种在本地运行一组Docker容器的便捷方式。
Example config files for a [session cluster](https://github.com/docker-flink/examples/blob/master/docker-compose.yml) and a [job cluster](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/docker-compose.yml) are available on GitHub.
Github上提供了 [安装](https://github.com/docker-flink/examples/blob/master/docker-compose.yml)[作业集群](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/docker-compose.yml) 的配置文件示例
### Usage
### 用法
* Launch a cluster in the foreground
* 启动集群
```
docker-compose up
```
* Launch a cluster in the background
* 后台启动集群
```
docker-compose up -d
```
* Scale the cluster up or down to _N_ TaskManagers
* 调整集群中为 _N_个 TaskManagers
```
docker-compose scale taskmanager=<N>
```
* Kill the cluster
* 关闭集群
```
docker-compose kill
```
When the cluster is running, you can visit the web UI at [http://localhost:8081](http://localhost:8081). You can also use the web UI to submit a job to a session cluster.
Flink集群运行时,可以通过 [http://localhost:8081](http://localhost:8081)来访问WEB UI,并通过UI来提交作业。
To submit a job to a session cluster via the command line, you must copy the JAR to the JobManager container and submit the job from there.
通过命令行将作业提交到Flink群集,必须将JAR复制到JobManager容器中并从那里提交作业。
For example:
例如:
```
$ JOBMANAGER_CONTAINER=$(docker ps --filter name=jobmanager --format={{.ID}})
......
# Kubernetes Setup
# Kubernetes 设置
This page describes how to deploy a Flink job and session cluster on [Kubernetes](https://kubernetes.io).
本章介绍如何在 [Kubernetes](https://kubernetes.io)上部署Flink作业
## Setup Kubernetes
## 安装 Kubernetes
Please follow [Kubernetes’ setup guide](https://kubernetes.io/docs/setup/) in order to deploy a Kubernetes cluster. If you want to run Kubernetes locally, we recommend using [MiniKube](https://kubernetes.io/docs/setup/minikube/).
按照 [Kubernetes’ setup guide](https://kubernetes.io/docs/setup/) 来部署kubernetes集群,如果需要在本地运行Kubernetes,建议使用 [MiniKube](https://kubernetes.io/docs/setup/minikube/).
**Note:** If using MiniKube please make sure to execute `minikube ssh 'sudo ip link set docker0 promisc on'` before deploying a Flink cluster. Otherwise Flink components are not able to self reference themselves through a Kubernetes service.
**注意:** 如果使用MiniKube,请确保在部署前执行 `minikube ssh 'sudo ip link set docker0 promisc on'` 命令,窦泽,Flink组件无法通过Kubernetes服务来引用自己
## Flink session cluster on Kubernetes
## Kubernetes上的Flink集群
A Flink session cluster is executed as a long-running Kubernetes Deployment. Note that you can run multiple Flink jobs on a session cluster. Each job needs to be submitted to the cluster after the cluster has been deployed.
Flink会话群集作为长期运行的Kubernetes部署而执行, 所以可以在集群中运行多个Flink作业,集群部署后,需要把任务逐个提交到集群。
A basic Flink session cluster deployment in Kubernetes has three components:
在Kubernetes上部署的Flink会话通常有三个组件:
* a Deployment/Job which runs the JobManager
* a Deployment for a pool of TaskManagers
* a Service exposing the JobManager’s REST and UI ports
* 部署/作业运行JobManager
* 部署TaskManagers池
* 提供 JobManager’的 REST的 UI服务和端口
### Deploy Flink session cluster on Kubernetes
### 在Kubernetes上部署Flink会话集群
Using the resource definitions for a [session cluster](#session-cluster-resource-definitions), launch the cluster with the `kubectl` command:
使用 `kubectl` 命令来定义 [session cluster](#session-cluster-resource-definitions)的资源 :
```
kubectl create -f jobmanager-service.yaml
......@@ -30,12 +30,12 @@ kubectl create -f jobmanager-deployment.yaml
kubectl create -f taskmanager-deployment.yaml
```
You can then access the Flink UI via `kubectl proxy`:
可以通过 `kubectl proxy` 来访问Flink UI:
1. Run `kubectl proxy` in a terminal
2. Navigate to [http://localhost:8001/api/v1/namespaces/default/services/flink-jobmanager:ui/proxy](http://localhost:8001/api/v1/namespaces/default/services/flink-jobmanager:ui/proxy) in your browser
1. 在终端执行`kubectl proxy` 命令
2. 在浏览器中输入 [http://localhost:8001/api/v1/namespaces/default/services/flink-jobmanager:ui/proxy](http://localhost:8001/api/v1/namespaces/default/services/flink-jobmanager:ui/proxy) 即可访问
In order to terminate the Flink session cluster, use `kubectl`:
需要停止Flink集群,使用 `kubectl`:
```
kubectl delete -f jobmanager-deployment.yaml
......@@ -43,27 +43,27 @@ kubectl delete -f taskmanager-deployment.yaml
kubectl delete -f jobmanager-service.yaml
```
## Flink job cluster on Kubernetes
## Kubernetes上的Flink集群
A Flink job cluster is a dedicated cluster which runs a single job. The job is part of the image and, thus, there is no extra job submission needed.
Flink作业集群是运行单个作业的专用集群。是镜像的一部分,所以不需要额外的工作
### Creating the job-specific image
### 创建专用作业的镜像
The Flink job cluster image needs to contain the user code jars of the job for which the cluster is started. Therefore, one needs to build a dedicated container image for every job. Please follow these [instructions](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/README.md) to build the Docker image.
Flink作业集群映像需要包含启动集群的作业的用户代码jar,因此,需要为每个作业构建专用的镜像。按照 [说明](https://github.com/apache/flink/blob/release-1.7/flink-container/docker/README.md) 来构建Docker镜像
### Deploy Flink job cluster on Kubernetes
### 在Kubernetes上部署Flink作业集群
In order to deploy the a job cluster on Kubernetes please follow these [instructions](https://github.com/apache/flink/blob/release-1.7/flink-container/kubernetes/README.md#deploy-flink-job-cluster).
在Kubernetes上部署作业集群,请参阅 [instructions](https://github.com/apache/flink/blob/release-1.7/flink-container/kubernetes/README.md#deploy-flink-job-cluster).
## Advanced Cluster Deployment
## 集群的高级部署
An early version of a [Flink Helm chart](https://github.com/docker-flink/examples) is available on GitHub.
GitHub 上提供了早期版本的[Flink Helm chart](https://github.com/docker-flink/examples)
## Appendix
## 附录
### Session cluster resource definitions
### 会话集群的资源文件
The Deployment definitions use the pre-built image `flink:latest` which can be found [on Docker Hub](https://hub.docker.com/r/_/flink/). The image is built from this [Github repository](https://github.com/docker-flink/docker-flink).
[on Docker Hub](https://hub.docker.com/r/_/flink/)上可以通过 `flink:latest`标签来找到已经构建好的镜像,镜像是从 [Github repository](https://github.com/docker-flink/docker-flink)这里构建的。
`jobmanager-deployment.yaml`
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册