將自行管理的 MySQL Metastore 遷移至 Dataproc Metastore

本頁說明如何建立 MySQL dump 檔案,並將中繼資料匯入現有的 Dataproc Metastore 服務,將外部自行管理的 MySQL 中繼儲存庫遷移至 Dataproc Metastore。

事前準備

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

    Go to project selector

  5. Make sure that billing is enabled for your Google Cloud project.

  6. Enable the Dataproc Metastore API.

    Enable the API

必要的角色

如要取得建立 Dataproc Metastore 和匯入 MySQL Metastore 的必要權限,請要求管理員授予您下列 IAM 角色:

  • 如要建立服務並匯入中繼資料:
  • 如要使用 Cloud Storage 物件 (SQL 傾印檔案) 匯入資料,請按照下列步驟操作:
    • Storage 物件檢視者 (roles/storage.objectViewer) 在 Dataproc Metastore 服務代理程式上。例如:service-CUSTOMER_PROJECT_NUMBER@gcp-sa-metastore.iam.gserviceaccount.com
    • Storage 物件檢視者 (roles/storage.objectViewer) 使用者帳戶。

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。

這些預先定義的角色具備建立 Dataproc Metastore 和匯入 MySQL Metastore 所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:

所需權限

如要建立 Dataproc Metastore 並匯入 MySQL Metastore,必須具備下列權限:

  • 建立服務: metastore.services.create 在專案中。
  • 如要匯入中繼資料: metastore.imports.create 專案。
  • 如要使用 Cloud Storage 物件 (SQL 傾印檔案) 匯入資料,請按照下列步驟操作:
    • storage.objects.get 在 Dataproc Metastore 服務代理程式上。例如:service-CUSTOMER_PROJECT_NUMBER@gcp-sa-metastore.iam.gserviceaccount.com
    • storage.objects.get 使用者帳戶。

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

如要進一步瞭解特定 Dataproc Metastore 角色和權限,請參閱「使用 IAM 管理 Dataproc 存取權」。

建立 Dataproc Metastore 服務

下列操作說明示範如何建立 Dataproc Metastore 服務,以便將 SQL 傾印檔案遷移至該服務。

控制台

  1. 在 Google Cloud 控制台中,開啟「建立服務」頁面:

    前往「建立服務」

    「建立服務」頁面。
    Dataproc Metastore「建立服務」頁面
  2. 在「Service name」(服務名稱) 欄位中輸入 example-service

  3. 選取「資料位置」。 如要瞭解如何選取區域,請參閱「Cloud 據點」一文。

  4. 其他服務設定選項請使用系統提供的預設值。

  5. 如要建立並啟動服務,請按一下「Submit」(提交) 按鈕。

新的服務會顯示在服務清單中。

gcloud

執行下列 gcloud metastore services create 指令來建立服務:

 gcloud metastore services create example-service \
     --location=LOCATION
 

LOCATION 替換為您要建立服務的 Compute Engine 地區。確認該區域支援 Dataproc Metastore

REST

按照 API 操作說明,使用 API Explorer 建立服務

為遷移作業做好準備

您現在必須準備儲存在 Hive Metastore 資料庫中的中繼資料,方法是建立 MySQL 轉儲檔案,並將其放入 Cloud Storage bucket,以供匯入。

如需遷移前準備步驟,請參閱「準備匯入檔案」。

匯入中繼資料

準備好傾印檔案後,請將其匯入 Dataproc Metastore 服務。

如要將中繼資料匯入 example-service 服務,請參閱將檔案匯入 Dataproc Metastore

建立及連結 Dataproc 叢集

將中繼資料匯入 Dataproc Metastore example-service 服務後,建立並附加 Dataproc 叢集,將該服務做為 Hive 中繼存放區。

清除所用資源

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

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

    Go to Manage resources

  2. If the project that you plan to delete is attached to an organization, expand the Organization list in the Name column.
  3. In the project list, select the project that you want to delete, and then click Delete.
  4. In the dialog, type the project ID, and then click Shut down to delete the project.

或者,您也可以刪除本教學課程中使用的資源:

  1. 刪除 Dataproc Metastore 服務。

    控制台

    1. 在 Google Cloud 控制台中,開啟 Dataproc Metastore 頁面:

      在Google Cloud 控制台中開啟 Dataproc Metastore

    2. 勾選服務名稱左側的方塊,選取 example-service

    3. 在「Dataproc Metastore」頁面頂端,按一下「Delete」即可刪除服務。

    4. 在對話方塊中按一下「刪除」,即可確認刪除。

    服務清單中不會再顯示該服務。

    gcloud

    執行下列 gcloud metastore services delete 指令,刪除服務:

     gcloud metastore services delete example-service \
         --location=LOCATION

    LOCATION 替換為您建立服務的 Compute Engine 區域。

    REST

    按照 API 操作說明,使用 API Explorer 刪除服務

    系統會立即刪除所有項目。

  2. 刪除 Dataproc Metastore 服務的 Cloud Storage bucket

後續步驟