104.md 2.6 KB
Newer Older
W
wizardforcel 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95


# Google Compute Engine设置

> 译者:[flink.sojb.cn](https://flink.sojb.cn/)


本文档提供了有关如何在[Google Compute Engine](https://cloud.google.com/compute/)群集上使用Hadoop 1或Hadoop 2完全自动设置Flink的说明。这是通过Google的[bdutil实现的](https://cloud.google.com/hadoop/bdutil),它启动了一个集群并使用Hadoop部署了Flink。要开始使用,请按照以下步骤 算子操作。

# 先决条件

> 译者:[flink.sojb.cn](https://flink.sojb.cn/)


## 安装Google Cloud SDK

请按照有关如何设置[Google Cloud SDK](https://cloud.google.com/sdk/)的说明进行 算子操作。特别是,请务必使用以下命令对Google Cloud进行身份验证:

```
gcloud auth login 
```

## 安装bdutil

目前,尚未发布包含Flink扩展的bdutil版本。但是,您可以从[GitHub](https://github.com/GoogleCloudPlatform/bdutil)获得Flink支持的最新版本的bdutil :

```
git clone https://github.com/GoogleCloudPlatform/bdutil.git 
```

下载源后,切换到新创建的`bdutil`目录并继续执行后续步骤。

# 在Google Compute Engine上部署Flink

> 译者:[flink.sojb.cn](https://flink.sojb.cn/)


## 设置一个桶

如果尚未这样做,请为bdutil配置和暂存文件创建一个存储桶。可以使用gsutil创建一个新存储桶:

```
gsutil mb gs://<bucket_name> 
```

## 调整bdutil配置

要使用bdutil部署Flink,请至少调整bdutil_env.sh中的以下变量。

```
CONFIGBUCKET="<bucket_name>"
PROJECT="<compute_engine_project_name>"
NUM_WORKERS=<number_of_workers>

# set this to 'n1-standard-2' if you're using the free trial

> 译者:[flink.sojb.cn](https://flink.sojb.cn/)

GCE_MACHINE_TYPE="<gce_machine_type>"

# for example: "europe-west1-d"

> 译者:[flink.sojb.cn](https://flink.sojb.cn/)

GCE_ZONE="<gce_zone>" 
```

## 调整Flink配置

bdutil的Flink扩展为您处理配置。您可以另外调整配置变量`extensions/flink/flink_env.sh`。如果您想进一步配置,请查看[配置Flink](https://flink.sojb.cn/config.html)。使用`bin/stop-cluster`和更改其配置后,您将不得不重新启动Flink `bin/start-cluster`

## 使用Flink创建一个集群

要在Google Compute Engine上显示Flink群集,请执行:

```
./bdutil -e extensions/flink/flink_env.sh deploy 
```

## 运行Flink示例作业:

```
./bdutil shell
cd /home/hadoop/flink-install/bin
./flink run ../examples/batch/WordCount.jar gs://dataflow-samples/shakespeare/othello.txt gs://<bucket_name>/output 
```

## 关闭群集

关闭集群就像执行一样简单

```
./bdutil -e extensions/flink/flink_env.sh delete 
```