Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Crea un cluster Dataproc
Requisiti:
Nome: il nome del cluster deve iniziare con una lettera minuscola seguita da un numero massimo di 51 lettere minuscole, numeri e trattini e non può terminare con un trattino.
Regione del cluster: devi specificare un'area geografica global o specifica per il cluster. L'area geografica globale è un endpoint speciale a più aree geografiche in grado di eseguire il deployment delle istanze in qualsiasi zona di Compute Engine specificata dall'utente.
Puoi anche specificare regioni distinte, ad esempio us-east1 o europe-west1, per isolare le risorse del cluster, ad esempio istanze VM e metadati del cluster archiviati in Cloud Storage, all'interno della regione specificata dall'utente.
Per informazioni sulla selezione di un'area geografica, consulta Aree geografiche disponibili e zone. Puoi anche eseguire il comando gcloud compute regions list per visualizzare un elenco delle aree geografiche disponibili.
Per creare un cluster Dataproc sulla riga di comando, esegui il comando Cloud SDK
gcloud dataproc clusters create
in locale in una finestra del terminale o in
Cloud Shell.
Il comando precedente crea un cluster con impostazioni di servizio Dataproc predefinite per le istanze di macchine virtuali master e worker, dimensioni e tipi di disco, tipo di rete, regione e zona in cui viene eseguito il deployment del cluster e altre impostazioni del cluster. Consulta il comando gcloud dataproc clusters create per informazioni sull'utilizzo dei flag della riga di comando per personalizzare le impostazioni del cluster.
Crea un cluster con un file YAML
Esegui il comando gcloud che segue per esportare la configurazione di un cluster Dataproc esistente in un file YAML.
Nota:durante l'esportazione, i filtri specifici dei cluster, come il nome del cluster, i campi di solo output e le etichette applicate automaticamente, vengono filtrati. Questi campi non sono consentiti nel file YAML importato utilizzato per creare un cluster.
REST &AM; LINEA CMD
Questa sezione mostra come creare un cluster con i valori richiesti e
la configurazione predefinita (1 master, 2 worker).
Prima di utilizzare i dati della richiesta, effettua le seguenti sostituzioni:
Apri la pagina Dataproc
Crea un cluster
nella console Google Cloud nel browser, quindi
fai clic su Crea nel cluster sulla riga Compute Engine
nella pagina Crea un cluster Dataproc su Compute Engine. Il riquadro
Configura cluster viene selezionato con i campi compilati con valori predefiniti. Puoi selezionare ogni riquadro e confermare o modificare i valori predefiniti per personalizzare il cluster.
Fai clic su Crea per creare il cluster. Il nome del cluster viene visualizzato nella pagina Cluster e il suo stato viene aggiornato in esecuzione dopo il provisioning del cluster. Fai clic sul nome del cluster per aprire la pagina dei dettagli del cluster, in cui puoi esaminare job, istanze e impostazioni di configurazione del cluster e connetterti alle interfacce web in esecuzione nel cluster.
importcom.google.api.gax.longrunning.OperationFuture;importcom.google.cloud.dataproc.v1.Cluster;importcom.google.cloud.dataproc.v1.ClusterConfig;importcom.google.cloud.dataproc.v1.ClusterControllerClient;importcom.google.cloud.dataproc.v1.ClusterControllerSettings;importcom.google.cloud.dataproc.v1.ClusterOperationMetadata;importcom.google.cloud.dataproc.v1.InstanceGroupConfig;importjava.io.IOException;importjava.util.concurrent.ExecutionException;publicclassCreateCluster{publicstaticvoidcreateCluster()throwsIOException,InterruptedException{// TODO(developer): Replace these variables before running the sample.StringprojectId="your-project-id";Stringregion="your-project-region";StringclusterName="your-cluster-name";createCluster(projectId,region,clusterName);}publicstaticvoidcreateCluster(StringprojectId,Stringregion,StringclusterName)throwsIOException,InterruptedException{StringmyEndpoint=String.format("%s-dataproc.googleapis.com:443",region);// Configure the settings for the cluster controller client.ClusterControllerSettingsclusterControllerSettings=ClusterControllerSettings.newBuilder().setEndpoint(myEndpoint).build();// Create a cluster controller client with the configured settings. The client only needs to be// created once and can be reused for multiple requests. Using a try-with-resources// closes the client, but this can also be done manually with the .close() method.try(ClusterControllerClientclusterControllerClient=ClusterControllerClient.create(clusterControllerSettings)){// Configure the settings for our cluster.InstanceGroupConfigmasterConfig=InstanceGroupConfig.newBuilder().setMachineTypeUri("n1-standard-2").setNumInstances(1).build();InstanceGroupConfigworkerConfig=InstanceGroupConfig.newBuilder().setMachineTypeUri("n1-standard-2").setNumInstances(2).build();ClusterConfigclusterConfig=ClusterConfig.newBuilder().setMasterConfig(masterConfig).setWorkerConfig(workerConfig).build();// Create the cluster object with the desired cluster config.Clustercluster=Cluster.newBuilder().setClusterName(clusterName).setConfig(clusterConfig).build();// Create the Cloud Dataproc cluster.OperationFuture<Cluster,ClusterOperationMetadata>createClusterAsyncRequest=clusterControllerClient.createClusterAsync(projectId,region,cluster);Clusterresponse=createClusterAsyncRequest.get();// Print out a success message.System.out.printf("Clustercreatedsuccessfully:%s",response.getClusterName());}catch(ExecutionExceptione){System.err.println(String.format("ErrorexecutingcreateCluster:%s",e.getMessage()));}}}
constdataproc=require('@google-cloud/dataproc');// TODO(developer): Uncomment and set the following variables// projectId = 'YOUR_PROJECT_ID'
// region = 'YOUR_CLUSTER_REGION'
// clusterName = 'YOUR_CLUSTER_NAME'
// Create a client with the endpoint set to the desired cluster regionconstclient=newdataproc.v1.ClusterControllerClient({apiEndpoint:`${region}-dataproc.googleapis.com`,projectId:projectId,});asyncfunctioncreateCluster(){// Create the cluster configconstrequest={projectId:projectId,region:region,cluster:{clusterName:clusterName,config:{masterConfig:{numInstances:1,machineTypeUri:'n1-standard-2',},workerConfig:{numInstances:2,machineTypeUri:'n1-standard-2',},},},};// Create the clusterconst[operation]=awaitclient.createCluster(request);const[response]=awaitoperation.promise();// Output a success messageconsole.log(`Cluster created successfully: ${response.clusterName}`);
fromgoogle.cloudimportdataproc_v1asdataprocdefcreate_cluster(project_id,region,cluster_name):
"""ThissamplewalksauserthroughcreatingaCloudDataprocclusterusingthePythonclientlibrary.Args:project_id(string):Projecttouseforcreatingresources.region(string):Regionwheretheresourcesshouldlive.cluster_name(string):Nametouseforcreatingacluster.
"""
# Create a client with the endpoint set to the desired cluster region.cluster_client=dataproc.ClusterControllerClient(client_options={"api_endpoint":f"{region}-dataproc.googleapis.com:443"})# Create the cluster config.cluster={
"project_id":project_id,
"cluster_name":cluster_name,
"config":{
"master_config":{"num_instances":1, "machine_type_uri": "n1-standard-2"},
"worker_config":{"num_instances":2, "machine_type_uri": "n1-standard-2"},},}# Create the cluster.operation=cluster_client.create_cluster(request={"project_id":project_id, "region":region, "cluster":cluster})result=operation.result()# Output a success message.print(f"Clustercreatedsuccessfully:{result.cluster_name}")
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problema di traduzione"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Altra"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Facile da capire"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Il problema è stato risolto"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Altra"
}]
{"lastModified": "Ultimo aggiornamento 2022-10-12 UTC."}
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2022-10-12 UTC."]]