Dataproc Hub adalah server JupyterHub yang disesuaikan. Admin mengonfigurasi dan membuat instance Dataproc Hub yang dapat memunculkan cluster Dataproc satu pengguna untuk menghosting lingkungan notebook Jupyter dan JupyterLab (lihat Menggunakan Dataproc Hub).
Meluncurkan Notebook untuk beberapa pengguna. Anda dapat membuat instance Vertex AI Workbench yang mendukung Dataproc atau menginstal plugin JupyterLab Dataproc di VM untuk menayangkan notebook kepada beberapa pengguna.
Tujuan
Tentukan konfigurasi cluster Dataproc (atau gunakan salah satu file konfigurasi yang telah ditentukan).
Tetapkan variabel lingkungan instance Dataproc Hub.
Buat instance Dataproc Hub.
Sebelum memulai
Jika Anda belum melakukannya, buat Google Cloud project dan bucket Cloud Storage.
Menyiapkan project
- 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.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Dataproc, Compute Engine, and Cloud Storage APIs.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Dataproc, Compute Engine, and Cloud Storage APIs.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
Membuat bucket Cloud Storage di project Anda untuk menyimpan data yang digunakan dalam tutorial ini.
- 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.
-
In the Get started section, do the following:
- Enter a globally unique name that meets the bucket naming requirements.
- To add a
bucket label,
expand the Labels section ( ),
click add_box
Add label, and specify a
key
and avalue
for your label.
-
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:
- Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data.
- 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 (Data encryption method. ), and select a
- Select any of the options under Data protection that you
want to set for your bucket.
-
In the Get started section, do the following:
- Click Create.
Menentukan konfigurasi cluster
Instance Dataproc Hub membuat cluster dari nilai konfigurasi yang terdapat dalam file konfigurasi cluster YAML.
Konfigurasi cluster Anda dapat menentukan fitur atau komponen apa pun yang tersedia untuk cluster Dataproc (seperti jenis mesin, tindakan inisialisasi, dan komponen opsional). Versi image cluster harus 1.4.13 atau yang lebih tinggi. Mencoba membuat cluster dengan versi image yang lebih rendah dari 1.4.13 akan menyebabkan error dan gagal.
Contoh file konfigurasi cluster YAML
clusterName: cluster-name config: softwareConfig: imageVersion: 2.2-ubuntu22 optionalComponents: - JUPYTER
Setiap konfigurasi harus disimpan di Cloud Storage. Anda dapat membuat dan menyimpan beberapa file konfigurasi untuk memberi pengguna pilihan saat mereka menggunakan Dataproc Hub untuk membuat lingkungan notebook cluster Dataproc.
Ada dua cara untuk membuat file konfigurasi cluster YAML:
Membuat file konfigurasi cluster YAML dari konsol
- Buka halaman Create a cluster di konsol Google Cloud , lalu pilih dan isi kolom untuk menentukan jenis cluster yang akan dibuat Dataproc Hub untuk pengguna.
- Di bagian bawah panel kiri, pilih "REST yang Setara".
- Salin blok JSON yang dihasilkan, tidak termasuk baris permintaan POST di awal, lalu tempel blok JSON ke dalam pengonversi JSON-ke-YAML online (telusuri "Konversi JSON ke YAML" secara online).
- Salin YAML yang dikonversi ke file cluster-config-filename.yaml lokal.
Mengekspor file konfigurasi cluster YAML dari cluster yang ada
- Buat cluster yang cocok dengan persyaratan Anda.
- Ekspor konfigurasi cluster ke file cluster-config-filename.yaml lokal.
gcloud dataproc clusters export cluster-name \ --destination cluster-config-filename.yaml \ --region region
Menyimpan file konfigurasi YAML di Cloud Storage
Salin file konfigurasi cluster YAML lokal Anda ke bucket Cloud Storage.
gcloud storage cp cluster-config-filename.yaml gs://bucket-name/
Menetapkan variabel lingkungan instance Dataproc Hub
Administrator dapat menetapkan variabel lingkungan hub yang tercantum dalam tabel di bawah ini untuk menetapkan atribut cluster Dataproc yang akan dihasilkan oleh pengguna hub.
Variabel | Deskripsi | Contoh |
---|---|---|
NOTEBOOKS_LOCATION | Bucket Cloud Storage atau folder bucket yang berisi notebook pengguna. Awalan `gs://` bersifat opsional. Default: Bucket staging Dataproc. | gs://bucket-name/ |
DATAPROC_CONFIGS | Daftar string jalur Cloud Storage yang dipisahkan koma ke
file konfigurasi cluster YAML. Awalan `gs://` bersifat opsional. Default: gs://dataproc-spawner-dist/example-configs/ . yang berisi example-cluster.yaml dan example-single-node.yaml yang telah ditentukan.
|
gs://cluster-config-filename.yaml |
DATAPROC_LOCATIONS_LIST | Akhiran zona di region tempat instance Dataproc Hub berada. Pengguna dapat memilih salah satu zona ini sebagai zona tempat cluster Dataproc mereka akan dibuat. Default: "b". | b,c,d |
DATAPROC_DEFAULT_SUBNET | Subnet tempat instance Dataproc Hub akan menghasilkan cluster Dataproc. Default: subnet instance Dataproc Hub. | https://www.googleapis.com/compute/v1/projects/project-id/regions/region/subnetworks/subnet-name |
DATAPROC_SERVICE_ACCOUNT | Akun layanan yang akan dijalankan VM Dataproc. Default: Jika tidak ditetapkan, akun layanan Dataproc default akan digunakan. | service-account@project-id.iam.gserviceaccount.com |
SPAWNER_DEFAULT_URL | Apakah akan menampilkan UI Jupyter atau JupyterLab pada cluster Dataproc yang dihasilkan secara default. Default: "/lab". | `/` atau `/lab`, masing-masing untuk Jupyter atau JupyterLab. |
DATAPROC_ALLOW_CUSTOM_CLUSTERS | Apakah akan mengizinkan pengguna untuk menyesuaikan cluster Dataproc mereka. Default: false. | "true" atau "false" |
DATAPROC_MACHINE_TYPES_LIST | Daftar jenis mesin yang diizinkan untuk dipilih pengguna untuk cluster Dataproc mereka yang dihasilkan, jika penyesuaian cluster (DATAPROC_ALLOW_CUSTOM_CLUSTERS) diaktifkan. Default: kosong (semua jenis mesin diizinkan). | n1-standard-4,n1-standard-8,e2-standard-4,n1-highcpu-4 |
NOTEBOOKS_EXAMPLES_LOCATION | Jalur Cloud Storage ke bucket notebook atau folder bucket yang akan didownload ke cluster Dataproc yang dihasilkan saat cluster dimulai. Default: kosong. | gs://bucket-name/ |
Menetapkan variabel lingkungan hub
Ada dua cara untuk menetapkan variabel lingkungan hub:
Menetapkan variabel lingkungan hub dari konsol
Saat membuat instance Dataproc Hub dari tab Notebook yang Dikelola Pengguna di halaman Dataproc→Workbench di konsol Google Cloud , Anda dapat mengklik tombol Isi untuk membuka formulir Isi Dataproc Hub yang memungkinkan Anda menetapkan setiap variabel lingkungan.
Menetapkan variabel lingkungan hub dalam file teks
Buat file. Anda dapat menggunakan editor teks untuk menetapkan variabel lingkungan instance Dataproc Hub dalam file lokal. Atau, Anda dapat membuat file dengan menjalankan perintah berikut setelah mengisi nilai placeholder dan mengubah atau menambahkan variabel beserta nilainya.
cat <<EOF > environment-variables-file DATAPROC_CONFIGS=gs://bucket/cluster-config-filename.yaml NOTEBOOKS_LOCATION=gs://bucket/notebooks DATAPROC_LOCATIONS_LIST=b,c EOF
Simpan file di Cloud Storage. Salin file variabel lingkungan instance Dataproc Hub lokal ke bucket Cloud Storage Anda.
gcloud storage cp environment-variable-filename gs://bucket-name/folder-name/
Menetapkan peran Identity and Access Management (IAM)
Dataproc Hub menyertakan identitas berikut dengan kemampuan berikut:
- Administrator: membuat instance Dataproc Hub
- Pengguna data dan ML: mengakses UI Dataproc Hub
- Akun layanan Dataproc Hub: mewakili Dataproc Hub
- Akun layanan Dataproc: mewakili cluster Dataproc yang dibuat oleh Dataproc Hub.
Setiap identitas memerlukan peran atau izin tertentu untuk melakukan tugas terkait. Tabel di bawah merangkum peran dan izin IAM yang diperlukan oleh setiap identitas.
Identitas | Jenis | Peran atau izin |
---|---|---|
Administrator Dataproc Hub | Akun pengguna atau Layanan | roles/notebooks.admin |
Pengguna Dataproc Hub | Pengguna | notebooks.instances.use, dataproc.clusters.use |
Hub Dataproc | Akun layanan | roles/dataproc.hubAgent |
Dataproc | Akun layanan | roles/dataproc.worker |
Membuat instance Dataproc Hub
Sebelum memulai: Untuk membuat instance Dataproc Hub dari konsol Google Cloud , akun pengguna Anda harus memiliki izin
compute.instances.create
. Selain itu, akun layanan instance—akun layanan default Compute Engine atau akun layanan yang ditentukan pengguna yang tercantum di IAM & admin > Service Accounts (lihat Akun layanan VM Dataproc)—harus memiliki iziniam.serviceAccounts.actAs
.Buka halaman Dataproc→Workbench di konsol Google Cloud , lalu pilih tab Notebook yang Dikelola Pengguna.
Jika tidak dipilih sebelumnya sebagai filter, klik kotak Filter, lalu pilih **Environment:Dataproc Hub"".
Klik Notebook Baru→Dataproc Hub.
Di halaman Create a user-managed notebook, berikan informasi berikut:
- Nama notebook: Nama instance Dataproc Hub.
- Region: Pilih region untuk instance Dataproc Hub. Cluster Dataproc yang dihasilkan oleh instance Dataproc Hub ini juga akan dibuat di region ini.
- Zone: Pilih zona dalam region yang dipilih.
- Lingkungan:
Environment
: PilihDataproc Hub
.Select a script to run after creation
(opsional): Anda dapat menyisipkan atau menjelajahi dan memilih skrip atau file yang dapat dieksekusi tindakan inisialisasi untuk dijalankan di cluster Dataproc yang dibuat.Populate Dataproc Hub (optional)
: Klik Isi untuk membuka formulir yang memungkinkan Anda menetapkan setiap variabel lingkungan hub (lihat Menetapkan variabel lingkungan instance Dataproc Hub untuk deskripsi setiap variabel). Dataproc menggunakan nilai default untuk variabel lingkungan yang tidak ditetapkan. Atau, Anda dapat menetapkan pasangankey:value
Metadata untuk menetapkan variabel lingkungan (lihat item berikutnya).Metadata
:- Jika Anda membuat file teks yang berisi setelan variabel lingkungan hub (lihat Menetapkan variabel lingkungan hub), berikan nama file sebagai
key
dan lokasi Cloud Storagegs://bucket-name/folder-name/environment-variable-filename
file sebagaivalue
. Dataproc menggunakan nilai default untuk variabel lingkungan yang tidak ditetapkan.
- Jika Anda membuat file teks yang berisi setelan variabel lingkungan hub (lihat Menetapkan variabel lingkungan hub), berikan nama file sebagai
- Konfigurasi mesin:
Machine Type
: Pilih jenis mesin Compute Engine.- Menetapkan opsi konfigurasi mesin lainnya.
- Opsi Lainnya:
- Anda dapat meluaskan dan menetapkan atau mengganti nilai default di bagian Disks, Networking, Permission, Security, dan Environment upgrade and system health.
- Klik Create untuk meluncurkan instance Dataproc Hub.
Link Buka JupyterLab untuk instance Dataproc Hub akan aktif setelah instance dibuat. Pengguna mengklik link ini untuk membuka halaman server JupyterHub guna mengonfigurasi dan membuat cluster JupyterLab Dataproc (lihat Menggunakan Dataproc Hub).
Pembersihan
Menghapus instance Dataproc Hub
- Untuk menghapus instance Dataproc Hub Anda:
gcloud compute instances delete --project=${PROJECT} ${INSTANCE_NAME}
Menghapus bucket
- Untuk menghapus bucket Cloud Storage yang Anda buat di bagian Sebelum memulai, termasuk file data yang disimpan di bucket:
gcloud storage rm gs://${BUCKET_NAME} --recursive