区域性端点

Dataproc 支持基于 Compute Engine 区域的区域端点。创建 Dataproc 集群时,您必须指定一个区域,例如“us-east1”或“europe-west1”。Dataproc 会隔离指定区域内的地区内的集群资源,例如虚拟机实例、Cloud Storage 和元数据存储空间。

您可以在创建集群时,选择指定集群区域内的可用区,例如“us-east1-a”或“europe-west1-b”。如果您未指定可用区,Dataproc 自动可用区布置将在指定集群区域内选择一个可用区来查找集群资源。

区域级命名空间对应于 Dataproc 资源 URI 的 /regions/REGION 段(例如,请参阅集群 networkUri)。

区域性端点语义

区域性端点名称遵循基于 Compute Engine 区域的标准命名约定。例如,美国中部区域的名称为 us-central1,西欧区域的名称为 europe-west1。运行 gcloud compute regions list 命令以查看可用区域的列表。

创建集群

gcloud

创建集群时,请使用必需的 --region 标志指定区域。

gcloud dataproc clusters create CLUSTER_NAME \
    --region=REGION \
    other args ...

REST API

clusters.create 请求中使用 REGION 网址参数指定集群区域。

gRPC

使用以下模式将客户端传输地址设置为区域端点:

REGION-dataproc.googleapis.com

Python (google-cloud-python) 示例

from google.cloud import dataproc_v1
from google.cloud.dataproc_v1.gapic.transports import cluster_controller_grpc_transport

transport = cluster_controller_grpc_transport.ClusterControllerGrpcTransport(
    address='us-central1-dataproc.googleapis.com:443')
client = dataproc_v1.ClusterControllerClient(transport)

project_id = 'my-project'
region = 'us-central1'
cluster = {...}

Java (google-cloud-java) 示例

ClusterControllerSettings settings =
     ClusterControllerSettings.newBuilder()
        .setEndpoint("us-central1-dataproc.googleapis.com:443")
        .build();
 try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create(settings)) {
   String projectId = "my-project";
   String region = "us-central1";
   Cluster cluster = Cluster.newBuilder().build();
   Cluster response =
       clusterControllerClient.createClusterAsync(projectId, region, cluster).get();
 }

控制台

在 Google Cloud 控制台中,在 Dataproc 创建集群页面上的设置集群面板的“位置”部分指定 Dataproc 区域。

后续步骤