Menjalankan instance notebook terkelola di dalam cluster Dataproc
Halaman ini menunjukkan cara menjalankan file notebook instance notebook terkelola di cluster Dataproc.
Sebelum memulai
- Sign in to your Google Cloud 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 Notebooks and Dataproc 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 Notebooks and Dataproc 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. -
Dataproc Worker (
roles/dataproc.worker) di project Anda -
Editor Dataproc (
roles/dataproc.editor) di cluster untuk izindataproc.clusters.use -
dataproc.agents.create -
dataproc.agents.delete -
dataproc.agents.get -
dataproc.agents.update -
dataproc.tasks.lease -
dataproc.tasks.listInvalidatedLeases -
dataproc.tasks.reportStatus -
dataproc.clusters.use Gateway komponen cluster harus diaktifkan.
Cluster harus memiliki komponen Jupyter.
Cluster harus berada di region yang sama dengan instance notebook terkelola Anda.
REGION: Google Cloud lokasi instance notebook terkelola AndaCLUSTER_NAME: nama cluster baru.Di konsol Google Cloud , buka halaman Managed notebooks.
Di samping nama instance notebook terkelola, klik Buka JupyterLab.
Di antarmuka JupyterLab instance notebook terkelola Anda, pilih File > Baru > Notebook.
Kernel yang tersedia pada cluster Dataproc Anda akan muncul di menu Pilih kernel. Pilih kernel yang ingin Anda gunakan, lalu klik Pilih.
File notebook baru akan terbuka.
Tambahkan kode ke file notebook baru, dan jalankan kodenya.
Di antarmuka JupyterLab instance notebook terkelola Anda, klik tombol File Browser, pilih file notebook yang ingin dijalankan, lalu buka.
Untuk membuka dialog Pilih kernel, klik nama kernel file notebook Anda, misalnya: Python (Lokal).
Untuk memilih kernel dari cluster Dataproc, pilih nama kernel yang menyertakan nama cluster Anda di bagian akhir. Misalnya, kernel PySpark di cluster Dataproc bernama
myclusterdiberi nama PySpark di mycluster.Klik Pilih untuk menutup dialog.
Sekarang Anda dapat menjalankan kode file notebook di cluster Dataproc.
- Pelajari Dataproc lebih lanjut.
Peran yang diperlukan
Untuk memastikan bahwa akun layanan memiliki izin yang diperlukan untuk menjalankan file notebook di cluster Serverless for Apache Spark, minta administrator Anda untuk memberikan peran IAM berikut kepada akun layanan:
Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.
Peran bawaan ini berisi izin yang diperlukan untuk menjalankan file notebook di cluster Serverless for Apache Spark. Untuk melihat izin yang benar-benar diperlukan, perluas bagian Izin yang diperlukan:
Izin yang diperlukan
Izin berikut diperlukan untuk menjalankan file notebook di cluster Serverless for Apache Spark:
Administrator Anda mungkin juga dapat memberi akun layanan izin ini dengan peran khusus atau peran yang telah ditetapkan sebelumnya.
Membuat cluster Dataproc
Untuk menjalankan file notebook instance notebook terkelola di cluster Dataproc, cluster Anda harus memenuhi kriteria berikut:
Untuk membuat cluster Dataproc, masukkan perintah berikut di Cloud Shell atau lingkungan lain tempat Google Cloud CLI diinstal.
gcloud dataproc clusters create CLUSTER_NAME\ --region=REGION \ --enable-component-gateway \ --optional-components=JUPYTER
Ganti kode berikut:
Setelah beberapa menit, cluster Dataproc Anda tersedia untuk digunakan. Pelajari lebih lanjut cara membuat cluster Dataproc.
Buka JupyterLab
Menjalankan file notebook di cluster Dataproc Anda
Anda dapat menjalankan file notebook di cluster Dataproc dari instance notebook terkelola mana pun dalam project dan region yang sama.
Menjalankan file notebook baru
Untuk mengubah kernel yang ingin digunakan setelah membuat file notebook, lihat bagian berikut.