建立資料 pipeline

本快速入門導覽課程會說明如何執行下列操作:

  1. 建立 Cloud Data Fusion 執行個體。
  2. 部署 Cloud Data Fusion 執行個體提供的範例管道。管道會執行下列操作:
    1. 讀取 Cloud Storage 中含有 NYT 最佳銷售數據資料的 JSON 檔案。
    2. 執行檔案轉換,以剖析及清除資料。
    3. 將上週低於 $25 美元的最佳評選書籍載入 BigQuery 中。

事前準備

  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. Enable the Cloud Data Fusion API.

    Enable the API

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

    Go to project selector

  5. Enable the Cloud Data Fusion API.

    Enable the API

建立 Cloud Data Fusion 執行個體

  1. 按一下「建立執行個體」

    前往「Instances」(執行個體)

  2. 輸入「Instance name」(執行個體名稱)
  3. 輸入執行個體的說明
  4. 輸入要建立執行個體的「Region」(區域)
  5. 選擇要使用的 Cloud Data Fusion 版本
  6. 選擇 Cloud Data Fusion 版本
  7. 針對 Cloud Data Fusion 6.2.3 以上版本,請在「授權」欄位中,選擇要在 Dataproc 中執行 Cloud Data Fusion 管道的 Dataproc 服務帳戶。預設值為 Compute Engine 帳戶,已預先選取。
  8. 按一下 [Create] (建立)。執行個體建立程序最多需要 30 分鐘才會完成。在 Cloud Data Fusion 建立執行個體時,會在「Instances」頁面上顯示執行個體名稱旁的進度輪盤。完成後,這個圖示會變成綠色勾號,代表您可以開始使用這個執行個體。

使用 Cloud Data Fusion 時,您必須同時使用 Google Cloud 主控台和獨立的 Cloud Data Fusion 網頁介面。

  • 您可以在 Google Cloud 主控台中執行下列操作:

    • 建立 Google Cloud 控制台專案
    • 建立及刪除 Cloud Data Fusion 執行個體
    • 查看 Cloud Data Fusion 執行個體詳細資料
  • 在 Cloud Data Fusion 網頁介面中,您可以使用各種頁面 (例如「Studio」或「Wrangler」) 使用 Cloud Data Fusion 功能。

如要瀏覽 Cloud Data Fusion 介面,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,開啟「Instances」(執行個體) 頁面。

    前往「Instances」(執行個體)

  2. 在執行個體的「動作」欄中,按一下「查看執行個體」連結。
  3. 在 Cloud Data Fusion 網頁介面中,使用左側導覽面板前往所需頁面。

部署樣本管道

您可以透過 Cloud Data Fusion Hub 取得樣本管道,以便分享可重複使用的 Cloud Data Fusion 管道、外掛程式和解決方案。

  1. 在 Cloud Data Fusion 網頁介面中,按一下「Hub」
  2. 按一下左側面板中的「管道」
  3. 按一下「Cloud Data Fusion Quickstart」管道。
  4. 按一下 [建立]。
  5. 在 Cloud Data Fusion 快速入門設定面板中,按一下「Finish」
  6. 按一下「自訂管道」

    管道的視覺化表示圖會顯示在「Studio」頁面上,這是用於開發資料整合管道的圖形介面。左側列出可用的管道外掛程式,管道則會顯示在主畫布區域。您可以將游標懸停在每個管道節點上,然後按一下「Properties」,以探索管道內容。每個節點的屬性選單可讓您查看與節點相關聯的物件和作業。

  7. 按一下右上方選單中的「部署」。這個步驟會將管道提交至 Cloud Data Fusion。您將在本快速入門的下一節中執行管道。

部署管道

檢視您的管道

部署的管道會顯示在管道詳細資料檢視畫面中,您可以在該畫面中執行下列操作:

  • 查看管道的結構和設定。
  • 手動執行管道或設定時間表或觸發條件。
  • 查看管道的執行歷史摘要,包含執行次數、記錄檔和指標。

複製服務帳戶

執行管道

在管道詳細資料檢視畫面中,按一下「Run」執行管道。

執行管道

執行管道時,Cloud Data Fusion 會執行下列操作:

  1. 佈建暫時性 Dataproc 叢集
  2. 使用 Apache Spark 在叢集上執行管道
  3. 刪除叢集

查看結果

管道會在幾分鐘後完成。管道狀態會變更為「Succeeded」(已完成),並顯示每個節點處理的記錄筆數。

管道執行作業已完成

  1. 前往 BigQuery 網頁版介面
  2. 如要查看結果範例,請前往專案中的 DataFusionQuickstart 資料集,按一下 top_rated_inexpensive 資料表,然後執行簡單查詢。例如:

    SELECT * FROM PROJECT_ID.GCPQuickStart.top_rated_inexpensive LIMIT 10
    

    PROJECT_ID 替換為您的專案 ID。

查看結果

清除所用資源

如要避免系統向您的 Google Cloud 帳戶收取您在本頁所用資源的費用,請按照下列步驟操作。

  1. 刪除 BigQuery 資料集,該資料集是您在此快速入門的管道所寫入的標的。
  2. 刪除 Cloud Data Fusion 執行個體

  3. 選用步驟:刪除專案。

  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.

後續步驟