地區端點

Dataproc 支援以 Compute Engine 地區為基礎的地區端點。建立 Dataproc 叢集時,您必須指定地區,例如「us-east1」或「europe-west1」。Dataproc 會在指定地區的可用區內,隔離叢集資源,例如 VM 執行個體、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 地區。

後續步驟