Menjalankan pipeline menggunakan builder tugas

Panduan memulai ini menunjukkan cara menjalankan tugas Dataflow menggunakan pembuat tugas Dataflow. Builder tugas adalah UI visual untuk membangun dan menjalankan pipeline Dataflow di konsol Google Cloud , tanpa perlu menulis kode apa pun.

Dalam panduan memulai ini, Anda akan memuat contoh pipeline ke dalam pembuat tugas, menjalankan tugas, dan memverifikasi bahwa tugas tersebut menghasilkan output.

Sebelum memulai

Selesaikan langkah-langkah berikut sebelum menjalankan pipeline Anda.

Menyiapkan project

  1. Sign in to your Google Cloud Platform 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.

    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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  4. Enable the Dataflow, Compute Engine, Cloud Logging, Cloud Storage, Google Cloud Storage JSON, and Resource Manager APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  7. Enable the Dataflow, Compute Engine, Cloud Logging, Cloud Storage, Google Cloud Storage JSON, and Resource Manager APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  8. Membuat bucket Cloud Storage:
    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. For Name your bucket, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.
      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. In the Set a default class section, select the following: Standard.
        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.

    Peran yang diperlukan

    Untuk mendapatkan izin yang Anda perlukan guna menjalankan panduan memulai cepat ini, minta administrator Anda untuk memberi Anda peran IAM berikut di project Anda:

    Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.

    Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

    Untuk memastikan bahwa akun layanan memiliki izin yang diperlukan untuk menjalankan panduan memulai ini, minta administrator untuk memberikan peran IAM berikut kepada akun layanan di project Anda:

    Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.

    Administrator Anda mungkin juga dapat memberikan izin yang diperlukan kepada akun layanan melalui peran khusus atau peran bawaan lainnya.

    Jaringan VPC

    Secara default, setiap project baru dimulai dengan jaringan default. Jika jaringan default untuk project Anda dinonaktifkan atau dihapus, Anda harus memiliki jaringan di project yang akun penggunanya memiliki peran Compute Network User (roles/compute.networkUser).

Memuat contoh pipeline

Pada langkah ini, Anda akan memuat contoh pipeline yang menghitung jumlah kata dalam King Lear karya Shakespeare.

  1. Buka halaman Jobs di konsol Google Cloud .

    Buka Tugas

  2. Klik Buat tugas dari template.

  3. Klik Job builder.

  4. Klik Load Blueprints.

  5. Klik Jumlah Kata. Penyusun tugas diisi dengan representasi grafis pipeline.

Untuk setiap langkah pipeline, builder tugas menampilkan kartu yang menentukan parameter konfigurasi untuk langkah tersebut. Misalnya, langkah pertama membaca file teks dari Cloud Storage. Lokasi data sumber sudah terisi otomatis di kotak Lokasi teks.

Screenshot builder tugas

Menetapkan lokasi output

Pada langkah ini, Anda akan menentukan bucket Cloud Storage tempat pipeline menulis output.

  1. Cari kartu berjudul Wastafel baru. Anda mungkin perlu men-scroll.

  2. Di kotak Lokasi teks, klik Jelajahi.

  3. Pilih nama bucket Cloud Storage yang Anda buat di bagian Sebelum memulai.

  4. Klik Lihat resource turunan.

  5. Di kotak Nama file, masukkan words.

  6. Klik Pilih.

Menjalankan tugas

Klik Jalankan tugas. Builder tugas membuat tugas Dataflow, lalu membuka grafik tugas. Saat tugas dimulai, grafik tugas akan menampilkan representasi grafis pipeline, yang mirip dengan yang ditampilkan di pembuat tugas. Saat setiap langkah pipeline berjalan, statusnya diperbarui dalam grafik tugas.

Panel Info tugas menampilkan status keseluruhan tugas. Jika tugas selesai dengan berhasil, kolom Status tugas akan diperbarui menjadi Succeeded.

Periksa output tugas

Setelah tugas selesai, lakukan langkah-langkah berikut untuk melihat output dari pipeline:

  1. Di konsol Google Cloud , buka halaman Bucket Cloud Storage.

    Buka Bucket

  2. Di daftar bucket, klik nama bucket yang Anda buat di Sebelum memulai.

  3. Klik file bernama words-00000-of-00001.

  4. Di halaman Object details, klik URL yang diautentikasi untuk melihat output pipeline.

Output-nya akan terlihat seperti berikut:

brother: 20
deeper: 1
wrinkles: 1
'alack: 1
territory: 1
dismiss'd: 1
[....]

Pembersihan

Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan pada halaman ini, ikuti langkah-langkah berikut.

Menghapus project

Cara termudah untuk menghilangkan penagihan adalah dengan menghapus Google Cloud project yang Anda buat untuk panduan memulai.

  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 resource satu per satu

Jika Anda ingin mempertahankan Google Cloud project yang Anda gunakan dalam panduan memulai ini, hapus bucket Cloud Storage:

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

    Go to Buckets

  2. Click the checkbox for the bucket that you want to delete.
  3. To delete the bucket, click Delete, and then follow the instructions.

Langkah berikutnya