建立 Dataproc 叢集時,您會指定 Compute Engine 區域,例如「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 指令,查看可用區域清單。
地點和區域端點
Google Cloud API 可支援位置和區域端點:
位置端點可確保透過私人連線存取資料時,傳輸中的資料會保留在指定位置。
格式:
{location}-{service}.googleapis.com範例:
us-central-1-dataproc.googleapis.com區域端點可確保透過私人連線或公用網際網路存取資料時,傳輸中的資料會保留在指定位置。
格式:
{service}.{location}.rep.googleapis.com範例:
dataproc.us-central1.rep.googleapis.com
預設 Dataproc 端點為位置端點。 如要瞭解 Dataproc 對區域端點的支援公告,請參閱 Dataproc 版本資訊。
建立叢集
gcloud CLI
建立叢集時,請使用必要 --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「Create a cluster」(建立叢集) 頁面,於「Set up cluster」(設定叢集) 面板的「Location」(位置) 區段中指定 Dataproc 地區。