建立 Managed Service for Apache Spark 叢集時,請指定 Compute Engine 區域,例如「us-east1」或「europe-west1」。Managed Service for Apache Spark 會在指定區域內的可用區中,隔離叢集資源,例如 VM 執行個體、Cloud Storage 和中繼資料儲存空間。
建立叢集時,您可以選擇在指定的叢集地區內指定區域,例如「us-east1-a」或「europe-west1-b」。如果未指定可用區,Managed Service for Apache Spark 自動選擇可用區位置功能會從您指定的叢集區域中,選擇叢集資源所在的可用區。
區域命名空間對應至 Managed Service for Apache Spark 資源 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
預設的 Managed Service for Apache Spark 端點為位置端點。如要瞭解 Managed Service for Apache Spark 對區域端點的支援公告,請參閱 Managed Service for Apache Spark 版本資訊。
建立叢集
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 控制台的 Managed Service for Apache Spark「Create a cluster」(建立叢集)頁面中,於「Set up cluster」(設定叢集)面板的「Location」(位置) 專區指定 Managed Service for Apache Spark 區域。
後續步驟
- 地理位置與區域
- Compute Engine Engine→地區與區域
- Compute Engine→全球、地區和區域資源
- Managed Service for Apache Spark 自動選擇可用區放置