Menginstal dan menjalankan notebook Jupyter di cluster Dataproc


Tujuan

Tutorial ini menunjukkan cara menginstal komponen Jupyter Dataproc pada cluster baru, lalu menghubungkan ke UI notebook Jupyter yang berjalan di cluster dari browser lokal menggunakan Component Gateway Dataproc.

Biaya

Dalam dokumen ini, Anda akan menggunakan komponen Google Cloudyang dapat ditagih berikut:

Untuk membuat perkiraan biaya berdasarkan proyeksi penggunaan Anda, gunakan kalkulator harga.

Pengguna Google Cloud baru mungkin memenuhi syarat untuk mendapatkan uji coba gratis.

Sebelum memulai

Jika Anda belum melakukannya, buat Google Cloud project dan bucket Cloud Storage.

  1. Menyiapkan project Anda

    1. 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.
    2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

      Go to project selector

    3. Verify that billing is enabled for your Google Cloud project.

    4. Enable the Dataproc, Compute Engine, and Cloud Storage APIs.

      Enable the APIs

    5. Install the Google Cloud CLI.

    6. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

    7. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

      gcloud init
    8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

      Go to project selector

    9. Verify that billing is enabled for your Google Cloud project.

    10. Enable the Dataproc, Compute Engine, and Cloud Storage APIs.

      Enable the APIs

    11. Install the Google Cloud CLI.

    12. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

    13. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

      gcloud init
    14. Membuat bucket Cloud Storage di project Anda untuk menyimpan notebook yang Anda buat dalam tutorial ini.

      1. In the Google Cloud console, go to the Cloud Storage Buckets page.

        Go to Buckets

      2. Click Create.
      3. On the Create a bucket page, enter your bucket information. To go to the next step, click Continue.
        1. 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 label, and specify a key and a value for your label.
        2. In the Choose where to store your data section, do the following:
          1. Select a Location type.
          2. Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
          3. To set up cross-bucket replication, select Add cross-bucket replication via Storage Transfer Service and follow these steps:

            Set up cross-bucket replication

            1. In the Bucket menu, select a bucket.
            2. 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.
        3. In the Choose how to store your data section, do the following:
          1. Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data.
          2. To enable hierarchical namespace, in the Optimize storage for data-intensive workloads section, select Enable hierarchical namespace on this bucket.
        4. 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.
        5. 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.
      4. Click Create.
      5. Notebook Anda akan disimpan di Cloud Storage di bagian gs://bucket-name/notebooks/jupyter.

    15. Membuat cluster dan menginstal komponen Jupyter

      Buat cluster dengan komponen Jupyter yang diinstal.

      Membuka UI Jupyter dan JupyterLab

      Klik link Google Cloud Component Gateway konsol di konsol Google Cloud untuk membuka notebook Jupyter atau UI JupyterLab yang berjalan di

      Direktori tingkat teratas yang ditampilkan oleh instance Jupyter Anda adalah direktori virtual yang memungkinkan Anda melihat konten bucket Cloud Storage atau sistem file lokal Anda. Anda dapat memilih salah satu lokasi dengan mengklik link GCS untuk Cloud Storage atau Local Disk untuk sistem file lokal node master di cluster Anda.

      1. Klik link GCS. UI web notebook Jupyter menampilkan notebook yang disimpan di bucket Cloud Storage Anda, termasuk notebook yang Anda buat dalam tutorial ini.

      Pembersihan

      Setelah menyelesaikan tutorial, Anda dapat membersihkan resource yang dibuat agar resource tersebut berhenti menggunakan kuota dan dikenai biaya. Bagian berikut menjelaskan cara menghapus atau menonaktifkan resource ini.

      Menghapus project

      Cara termudah untuk menghilangkan penagihan adalah dengan menghapus project yang Anda buat untuk tutorial.

      Untuk menghapus project:

      1. In the Google Cloud console, go to the Manage resources page.

        Go to Manage resources

      2. In the project list, select the project that you want to delete, and then click Delete.
      3. In the dialog, type the project ID, and then click Shut down to delete the project.

      Menghapus cluster

      • Untuk menghapus cluster Anda:
        gcloud dataproc clusters delete cluster-name \
            --region=${REGION}
        

      Menghapus bucket

      • Untuk menghapus bucket Cloud Storage yang Anda buat di bagian Sebelum memulai, langkah 2, termasuk notebook yang disimpan di bucket:
        gcloud storage rm gs://${BUCKET_NAME} --recursive
        

      Langkah berikutnya