Menjalankan pipeline menggunakan pembuat tugas

Panduan memulai ini menunjukkan cara menjalankan tugas Dataflow menggunakan pembangun tugas Dataflow. Builder tugas adalah UI visual untuk mem-build 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 membuat output.

Sebelum memulai

  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. Make sure 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.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure 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.

    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.
  9. Untuk menyelesaikan langkah-langkah dalam panduan memulai ini, akun pengguna Anda harus memiliki peran Admin Dataflow dan peran Pengguna Akun Layanan. Akun layanan default Compute Engine harus memiliki peran Dataflow Worker. Untuk menambahkan peran yang diperlukan di konsol Google Cloud:

    1. Buka halaman IAM.
      Buka IAM
    2. Pilih project Anda.
    3. Di baris yang berisi akun pengguna Anda, klik Edit akun utama
    4. Klik Tambahkan peran lain, lalu di menu drop-down, pilih Dataflow Admin.
    5. Klik Tambahkan peran lainnya, lalu di menu drop-down, pilih Pengguna Akun Layanan.
    6. Klik Simpan.
    7. Pada baris yang berisi akun layanan default Compute Engine, klik Edit principal.
    8. Klik Tambahkan peran lain, lalu di menu drop-down, pilih Dataflow Worker.
    9. Klik Tambahkan peran lain, lalu di menu drop-down, pilih Storage Object Admin.
    10. Klik Simpan.

      Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Memberikan peran IAM menggunakan konsol.

  10. 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 kata dalam King Lear Shakespeare.

  1. Buka halaman Jobs di konsol Google Cloud.

    Buka Tugas

  2. Klik Create job from template.

  3. Klik Job builder.

  4. Klik Muat.

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

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

Screenshot pembuat tugas

Menetapkan lokasi output

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

  1. Temukan kartu berjudul Sink baru. Anda mungkin perlu men-scroll.

  2. Di kotak Text location, klik Browse.

  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 Run job. Builder tugas membuat tugas Dataflow, lalu membuka grafik tugas. Saat tugas dimulai, grafik tugas akan menampilkan representasi grafis pipeline, mirip dengan yang ditampilkan di pembuat tugas. Saat setiap langkah pipeline berjalan, status akan diperbarui di grafik tugas.

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

Memeriksa 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 Buckets

  2. Dalam daftar bucket, klik nama bucket yang Anda buat di bagian 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 di halaman ini, ikuti langkah-langkah berikut.

Menghapus project

Cara termudah untuk menghilangkan penagihan adalah dengan menghapus project Google Cloud 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 project Google Cloud yang digunakan 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