Esegui una pipeline utilizzando il builder di job
Questa guida rapida mostra come eseguire un job Dataflow utilizzando il builder dei job Dataflow. Lo strumento di creazione dei job è un'interfaccia utente visiva per creare ed eseguire pipeline Dataflow nella console Google Cloud , senza scrivere codice.
In questa guida rapida, caricherai una pipeline di esempio nel builder dei job, eseguirai un job e verificherai che il job abbia creato un output.
Prima di iniziare
Completa i seguenti passaggi prima di eseguire la pipeline.
Configura il progetto
- Sign in to your Google Cloud Platform account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Dataflow, Compute Engine, Cloud Logging, Cloud Storage, Google Cloud Storage JSON, and Resource Manager APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Dataflow, Compute Engine, Cloud Logging, Cloud Storage, Google Cloud Storage JSON, and Resource Manager APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. - Crea un bucket Cloud Storage:
- In the Google Cloud console, go to the Cloud Storage Buckets page.
- Click Create.
- On the Create a bucket page, enter your bucket information. To go to the next
step, click Continue.
- For Name your bucket, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.
-
In the Choose where to store your data section, do the following:
- Select a Location type.
- Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
- If you select the dual-region location type, you can also choose to enable turbo replication by using the relevant checkbox.
- To set up cross-bucket replication, select
Add cross-bucket replication via Storage Transfer Service and
follow these steps:
Set up cross-bucket replication
- In the Bucket menu, select a bucket.
In the Replication settings section, click Configure to configure settings for the replication job.
The Configure cross-bucket replication pane appears.
- To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click Add a prefix.
- To set a storage class for the replicated objects, select a storage class from the Storage class menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.
- Click Done.
-
In the Choose how to store your data section, do the following:
- In the Set a default class section, select the following: Standard.
- To enable hierarchical namespace, in the Optimize storage for data-intensive workloads section, select Enable hierarchical namespace on this bucket.
- In the Choose how to control access to objects section, select whether or not your bucket enforces public access prevention, and select an access control method for your bucket's objects.
-
In the Choose how to protect object data section, do the
following:
- Select any of the options under Data protection that you
want to set for your bucket.
- To enable soft delete, click the Soft delete policy (For data recovery) checkbox, and specify the number of days you want to retain objects after deletion.
- To set Object Versioning, click the Object versioning (For version control) checkbox, and specify the maximum number of versions per object and the number of days after which the noncurrent versions expire.
- To enable the retention policy on objects and buckets, click the Retention (For compliance) checkbox, and then do the following:
- To enable Object Retention Lock, click the Enable object retention checkbox.
- To enable Bucket Lock, click the Set bucket retention policy checkbox, and choose a unit of time and a length of time for your retention period.
- To choose how your object data will be encrypted, expand the Data encryption section (), and select a Data encryption method.
- Select any of the options under Data protection that you
want to set for your bucket.
- Click Create.
-
Dataflow Developer (
roles/dataflow.developer) -
Utente Service Account (
roles/iam.serviceAccountUser) -
Dataflow Worker (
roles/dataflow.worker) -
Storage Object Admin (
roles/storage.objectAdmin)
Ruoli obbligatori
Per ottenere le autorizzazioni necessarie per eseguire questa guida rapida, chiedi all'amministratore di concederti i seguenti ruoli IAM sul tuo progetto:
Per saperne di più sulla concessione dei ruoli, consulta Gestisci l'accesso a progetti, cartelle e organizzazioni.
Potresti anche riuscire a ottenere le autorizzazioni richieste tramite i ruoli personalizzati o altri ruoli predefiniti.
Per assicurarti che i service account dispongano delle autorizzazioni necessarie per eseguire questa guida rapida, chiedi all'amministratore di concedere ai service account i seguenti ruoli IAM sul tuo progetto:
Per saperne di più sulla concessione dei ruoli, consulta Gestisci l'accesso a progetti, cartelle e organizzazioni.
L'amministratore potrebbe anche essere in grado di concedere ai service account le autorizzazioni richieste tramite ruoli personalizzati o altri ruoli predefiniti.
Rete VPC
Per impostazione predefinita, ogni nuovo progetto viene avviato con una
rete predefinita.
Se la rete predefinita per il tuo progetto è disattivata
o è stata eliminata, devi disporre di una rete nel tuo progetto per la quale
il tuo account utente dispone del
ruolo Utente di rete Compute
(roles/compute.networkUser).
Carica la pipeline di esempio
In questo passaggio, carichi una pipeline di esempio che conta le parole del Re Lear di Shakespeare.
Vai alla pagina Job nella console Google Cloud .
Fai clic su Crea job da modello.
Fai clic su Generatore di job.
Fai clic su Carica progetti.
Fai clic su Conteggio parole. Il builder dedicato viene compilato con una rappresentazione grafica della pipeline.
Per ogni passaggio della pipeline, il generatore di job mostra una scheda che specifica i parametri di configurazione per quel passaggio. Ad esempio, il primo passaggio legge i file di testo da Cloud Storage. La posizione dei dati di origine è precompilata nella casella Posizione testo.
Impostare la posizione di output
In questo passaggio, specifichi un bucket Cloud Storage in cui la pipeline scrive l'output.
Individua la scheda intitolata Nuovo lavello. Potrebbe essere necessario scorrere.
Nella casella Posizione testo, fai clic su Sfoglia.
Seleziona il nome del bucket Cloud Storage che hai creato in Prima di iniziare.
Fai clic su Visualizza risorse figlio.
Nella casella Nome file, inserisci
words.Fai clic su Seleziona.
Esegui il job
Fai clic su Esegui job. Il builder dei job crea un job Dataflow e poi passa al grafico del job. Quando il job inizia, il grafico del job mostra una rappresentazione grafica della pipeline, simile a quella mostrata nel generatore di job. Man mano che viene eseguito ogni passaggio della pipeline, lo stato viene aggiornato nel grafico dei job.
Il riquadro Informazioni job mostra lo stato generale del job. Se il job viene completato
correttamente, il campo Stato del job viene aggiornato a Succeeded.
Esamina l'output del job
Al termine del job, esegui i seguenti passaggi per visualizzare l'output della pipeline:
Nella console Google Cloud , vai alla pagina Bucket in Cloud Storage.
Nell'elenco dei bucket, fai clic sul nome del bucket che hai creato in Prima di iniziare.
Fai clic sul file denominato
words-00000-of-00001.Nella pagina Dettagli oggetto, fai clic sull'URL autenticato per visualizzare l'output della pipeline.
L'output dovrebbe essere simile al seguente:
brother: 20
deeper: 1
wrinkles: 1
'alack: 1
territory: 1
dismiss'd: 1
[....]
Esegui la pulizia
Per evitare che al tuo account Google Cloud vengano addebitati costi relativi alle risorse utilizzate in questa pagina, segui questi passaggi.
Elimina il progetto
Il modo più semplice per eliminare la fatturazione è eliminare il Google Cloud progetto che hai creato per la guida rapida.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
Elimina le singole risorse
Se vuoi conservare il progetto Google Cloud che hai utilizzato in questa guida rapida, elimina il bucket Cloud Storage:
- In the Google Cloud console, go to the Cloud Storage Buckets page.
- Click the checkbox for the bucket that you want to delete.
- To delete the bucket, click Delete, and then follow the instructions.