Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
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.
Untuk memastikan bahwa akun layanan memiliki izin yang diperlukan untuk menjalankan file notebook di cluster Dataproc Serverless, minta administrator Anda untuk memberikan peran IAM berikut kepada akun layanan:
Peran yang telah ditentukan ini berisi
izin yang diperlukan untuk menjalankan file notebook di cluster Dataproc Serverless. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:
Izin yang diperlukan
Izin berikut diperlukan untuk menjalankan file notebook di cluster Dataproc Serverless:
dataproc.agents.create
dataproc.agents.delete
dataproc.agents.get
dataproc.agents.update
dataproc.tasks.lease
dataproc.tasks.listInvalidatedLeases
dataproc.tasks.reportStatus
dataproc.clusters.use
Administrator Anda mungkin juga dapat memberi akun layanan
izin ini
dengan peran khusus atau
peran bawaan lainnya.
Membuat cluster Dataproc
Untuk menjalankan file notebook instance notebook terkelola
di cluster Dataproc, cluster Anda harus memenuhi
kriteria berikut:
Di samping nama instance notebook terkelola,
klik 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
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.
Untuk mengubah kernel yang ingin digunakan
setelah membuat file notebook, lihat bagian berikut.
Menjalankan file notebook yang ada
Di antarmuka JupyterLab instance notebook terkelola Anda,
klik
tombol folderFile 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 mycluster diberi nama PySpark di mycluster.
Klik Pilih untuk menutup dialog.
Sekarang Anda dapat menjalankan kode file notebook
di cluster Dataproc.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[],[],null,["# Run a managed notebooks instance on a Dataproc cluster\n======================================================\n\n\n| Vertex AI Workbench managed notebooks is\n| [deprecated](/vertex-ai/docs/deprecations). On\n| April 14, 2025, support for\n| managed notebooks will end and the ability to create managed notebooks instances\n| will be removed. Existing instances will continue to function\n| but patches, updates, and upgrades won't be available. To continue using\n| Vertex AI Workbench, we recommend that you\n| [migrate\n| your managed notebooks instances to Vertex AI Workbench instances](/vertex-ai/docs/workbench/managed/migrate-to-instances).\n\n\u003cbr /\u003e\n\nThis page shows you how to run a managed notebooks instance's\nnotebook file on a Dataproc cluster.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Notebooks and Dataproc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,dataproc)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Notebooks and Dataproc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=notebooks.googleapis.com,dataproc)\n\n1. If you haven't already, [create\n a managed notebooks instance](/vertex-ai/docs/workbench/managed/create-instance#create).\n\n### Required roles\n\n\nTo ensure that the service account has the necessary\npermissions to run a notebook file on a Dataproc Serverless cluster,\n\nask your administrator to grant the service account the\nfollowing IAM roles:\n\n| **Important:** You must grant these roles to the service account, *not* to your user account. Failure to grant the roles to the correct principal might result in permission errors.\n\n- [Dataproc Worker](/iam/docs/roles-permissions/dataproc#dataproc.worker) (`roles/dataproc.worker`) on your project\n- [Dataproc Editor](/iam/docs/roles-permissions/dataproc#dataproc.editor) (`roles/dataproc.editor`) on the cluster for the `dataproc.clusters.use` permission\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThese predefined roles contain\n\nthe permissions required to run a notebook file on a Dataproc Serverless cluster. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to run a notebook file on a Dataproc Serverless cluster:\n\n- ` dataproc.agents.create `\n- ` dataproc.agents.delete `\n- ` dataproc.agents.get `\n- ` dataproc.agents.update `\n- ` dataproc.tasks.lease `\n- ` dataproc.tasks.listInvalidatedLeases `\n- ` dataproc.tasks.reportStatus `\n- ` dataproc.clusters.use`\n\n\nYour administrator might also be able to give the service account\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nCreate a Dataproc cluster\n-------------------------\n\nTo run a managed notebooks instance's notebook file\nin a Dataproc cluster, your cluster must meet the following\ncriteria:\n\n- The cluster's component gateway must be enabled.\n\n- The cluster must have\n the [Jupyter component](/dataproc/docs/concepts/components/jupyter).\n\n- The cluster must be in the same region as\n your managed notebooks instance.\n\nTo create your Dataproc cluster,\nenter the following command in either\n[Cloud Shell](https://console.cloud.google.com?cloudshell=true) or another\nenvironment where the [Google Cloud CLI](/sdk/docs) is installed. \n\n```bash\ngcloud dataproc clusters create CLUSTER_NAME\\\n --region=REGION \\\n --enable-component-gateway \\\n --optional-components=JUPYTER\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the Google Cloud location of\n your managed notebooks instance\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your new\n cluster\n\nAfter a few minutes, your Dataproc cluster\nis available for use. [Learn more about creating Dataproc\nclusters](/dataproc/docs/guides/create-cluster).\n\nOpen JupyterLab\n---------------\n\n1. If you haven't already,\n [create\n a managed notebooks instance](/vertex-ai/docs/workbench/managed/create-instance#create) in the same region\n where your Dataproc cluster is.\n\n2. In the Google Cloud console, go to the **Managed notebooks** page.\n\n [Go to Managed notebooks](https://console.cloud.google.com/vertex-ai/workbench/managed)\n3. Next to your managed notebooks instance's name,\n click **Open JupyterLab**.\n\nRun a notebook file in your Dataproc cluster\n--------------------------------------------\n\nYou can run a notebook file in your Dataproc cluster\nfrom any managed notebooks instance in the same project and\nregion.\n\n### Run a new notebook file\n\n1. In your managed notebooks instance's JupyterLab interface,\n select **File \\\u003e\n New \\\u003e Notebook**.\n\n2. Your Dataproc cluster's available kernels appear in\n the **Select kernel** menu. Select the kernel that you want to use,\n and then click **Select**.\n\n Your new notebook file opens.\n3. Add code to your new notebook file, and run the code.\n\nTo change the kernel that you want to use\nafter you've created your notebook file, see the following section.\n\n### Run an existing notebook file\n\n1. In your managed notebooks instance's JupyterLab interface,\n click the\n folder **File Browser** button,\n navigate to the notebook file that you want to run, and open it.\n\n2. To open the **Select kernel** dialog, click the kernel name of your notebook\n file, for example: **Python (Local)**.\n\n3. To select a kernel from your Dataproc cluster,\n select a kernel name that includes your cluster name at the end of it.\n For example, a PySpark kernel on a Dataproc cluster\n named `mycluster` is named **PySpark on mycluster**.\n\n4. Click **Select** to close the dialog.\n\n You can now run your notebook file's code\n on the Dataproc cluster.\n\nWhat's next\n-----------\n\n- Learn more about [Dataproc](/dataproc/docs/concepts/overview)."]]