Dataproc-Cluster mithilfe von Clientbibliotheken erstellen
Der unten aufgeführte Beispielcode zeigt Ihnen, wie Sie mit den Cloud-Clientbibliotheken einen Dataproc-Cluster erstellen, einen Job im Cluster ausführen und anschließend den Cluster löschen.
Sie können die Aufgaben auch hiermit ausführen:
- API REST-Anfragen in Kurzanleitung: API Explorer verwenden
- Google Cloud Console. Erstellen Sie einen Dataproc-Cluster mit der Google Cloud Console
- Google Cloud CLI unter Dataproc-Cluster mit der Google Cloud-Befehlszeile erstellen
Hinweis
- Melden Sie sich bei Ihrem Google Cloud-Konto an. Wenn Sie mit Google Cloud noch nicht vertraut sind, erstellen Sie ein Konto, um die Leistungsfähigkeit unserer Produkte in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Die Abrechnung für das Google Cloud-Projekt muss aktiviert sein.
-
Enable the Dataproc API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Die Abrechnung für das Google Cloud-Projekt muss aktiviert sein.
-
Enable the Dataproc API.
Code ausführen
Schritt-für-Schritt-Anleitung ansehen:Klicken Sie auf In Cloud Shell öffnen, um eine Schritt-für-Schritt-Anleitung für Python Cloud-Clientbibliotheken auszuführen, mit der ein Cluster erstellt, ein PySpark-Job ausgeführt und dann den Cluster gelöscht wird.
Go
- Installieren Sie die Clientbibliothek. Weitere Informationen finden Sie unter Entwicklungsumgebung einrichten.
- Authentifizierung einrichten
- Klonen Sie GitHub-Beispielcode und führen Sie ihn aus.
- Sehen Sie sich die Ausgabe an. Der Code gibt das Jobtreiberlog an den standardmäßigen Dataproc-Staging-Bucket in Cloud Storage aus. Sie können die Jobtreiberausgabe in der Google Cloud Console im Abschnitt Jobs Ihres Dataproc-Projekts ansehen. Klicken Sie auf die Job-ID, um die Jobausgabe auf der Seite "Jobdetails" anzuzeigen.
Java
- Installieren Sie die Clientbibliothek. Weitere Informationen finden Sie unter Java-Entwicklungsumgebung einrichten.
- Authentifizierung einrichten
- Klonen Sie GitHub-Beispielcode und führen Sie ihn aus.
- Sehen Sie sich die Ausgabe an. Der Code gibt das Jobtreiberlog an den standardmäßigen Dataproc-Staging-Bucket in Cloud Storage aus. Sie können die Jobtreiberausgabe in der Google Cloud Console im Abschnitt Jobs Ihres Dataproc-Projekts ansehen. Klicken Sie auf die Job-ID, um die Jobausgabe auf der Seite "Jobdetails" anzuzeigen.
Node.js
- Installieren Sie die Clientbibliothek. Weitere Informationen finden Sie unter Node.js-Entwicklungsumgebung einrichten.
- Authentifizierung einrichten
- Klonen Sie GitHub-Beispielcode und führen Sie ihn aus.
- Sehen Sie sich die Ausgabe an. Der Code gibt das Jobtreiberlog an den standardmäßigen Dataproc-Staging-Bucket in Cloud Storage aus. Sie können die Jobtreiberausgabe in der Google Cloud Console im Abschnitt Jobs Ihres Dataproc-Projekts ansehen. Klicken Sie auf die Job-ID, um die Jobausgabe auf der Seite "Jobdetails" anzuzeigen.
Python
- Installieren Sie die Clientbibliothek. Weitere Informationen finden Sie unter Python-Entwicklungsumgebung einrichten.
- Authentifizierung einrichten
- Klonen Sie GitHub-Beispielcode und führen Sie ihn aus.
- Sehen Sie sich die Ausgabe an. Der Code gibt das Jobtreiberlog an den standardmäßigen Dataproc-Staging-Bucket in Cloud Storage aus. Sie können die Jobtreiberausgabe in der Google Cloud Console im Abschnitt Jobs Ihres Dataproc-Projekts ansehen. Klicken Sie auf die Job-ID, um die Jobausgabe auf der Seite "Jobdetails" anzuzeigen.
Weitere Informationen
- Weitere Informationen finden Sie unter Zusätzliche Ressourcen.