從備份還原 Dataproc Metastore

本頁說明如何從備份還原 Dataproc Metastore 服務。

備份是 Dataproc Metastore 服務中儲存的設定和中繼資料快照。您可以使用還原功能,快速設定新的 Dataproc Metastore 服務,並使用先前儲存在備份中的資料。

事前準備

必要的角色

如要取得從備份還原 Dataproc Metastore 服務所需的權限,請要求管理員授予您下列 IAM 角色:

  • 如要授予 Dataproc Metastore 資源的完整控制權,以便完成備份作業,請執行下列操作:
  • 如要使用儲存排定備份的 Cloud Storage 物件,請按照下列步驟操作: Cloud Storage 物件使用者 (roles/storage.objectUser) 在 Dataproc Metastore 服務代理上

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

這些預先定義的角色包含從備份還原 Dataproc Metastore 服務所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:

所需權限

如要從備份還原 Dataproc Metastore 服務,必須具備下列權限:

  • 如要還原中繼資料服務,請按照下列步驟操作: metastore.services.restore, metastore.backups.use
  • 如要使用 Cloud Storage 物件,請按照下列步驟操作:
    • orgpolicy.policy.get
    • resourcemanager.projects.get
    • resourcemanager.projects.list
    • storage.managedFolders.create
    • storage.managedFolders.delete
    • storage.managedFolders.get
    • storage.managedFolders.list
    • storage.multipartUploads.*
    • storage.objects.create
    • storage.objects.delete
    • storage.objects.get
    • storage.objects.list
    • storage.objects.restore
    • storage.objects.update

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

如要進一步瞭解特定 Dataproc Metastore 角色和權限,請參閱 Dataproc Metastore 身分與存取權管理總覽

關於從備份還原

從備份還原服務時,您可以選擇下列其中一個選項:

  • 還原備份中儲存的所有中繼資料和設定。
  • 還原所有中繼資料,但不還原備份中儲存的設定。而是保留目前的設定。

    設定包括 Dataproc Metastore 參數,例如服務名稱、通訊埠號碼和網路設定。中繼資料包含儲存在 Dataproc Metastore 服務中的所有資料庫和資料表資訊。

注意事項

  • 還原作業執行期間,您無法更新服務,例如無法變更設定。不過,您仍可使用服務執行一般作業,例如從已連結的 Dataproc 或自行管理的叢集中存取中繼資料。

  • 不會還原 Dataproc Metastore 標籤。

  • 資料倉儲目錄中儲存的資料不會還原。

  • 從備份還原不會還原或取代精細 IAM 政策。

  • 如要從排程備份還原,備份必須位於 Cloud Storage 值區中。

從備份還原

如要從備份還原 Dataproc Metastore 服務,請完成下列步驟。

  • 如果您使用的是 Google Cloud 主控台,則只能從與新服務相同的專案和區域建立的備份中還原中繼資料。

  • 如果您使用 Google Cloud CLI 或 Dataproc Metastore API,可以從在不同專案和地區建立的備份中還原中繼資料 (跨服務備份)。

控制台

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

    開啟 Dataproc Metastore

  2. 在「Dataproc Metastore」頁面中,按一下要從備份還原的服務名稱。

    「服務詳細資料」頁面隨即開啟。

    服務詳細資料頁面
    圖 1. Dataproc Metastore 服務詳細資料頁面
  3. 如要查看備份內容,請按一下「備份/還原」分頁標籤。

  4. 選取要使用的備份。方法是按一下「選單」圖示 ,然後選取「還原」

    「Restore」頁面隨即開啟。

    您也可以在「備份詳細資料」頁面還原服務。方法是按一下備份名稱,然後點選「還原」

  5. 選取適當的還原作業:

    • 還原中繼資料庫資料。還原所有中繼資料,但不會還原備份中儲存的設定
    • 還原 Metastore 資料和服務設定。還原備份中儲存的所有中繼資料和設定。
  6. 如要更新服務,請按一下「還原」

    返回「Dataproc Metastore」頁面,確認服務已成功備份。

    還原作業完成後,無論還原作業是否成功,Dataproc Metastore 都會自動返回有效狀態

gcloud CLI

  1. 如要還原 Dataproc Metastore 服務,請執行下列 gcloud metastore services restore 指令:

    gcloud metastore services restore SERVICE  \
        --project=PROJECT_ID \
        --location=LOCATION \
        --backup=BACKUP \
        --restore-type=RESTORE_TYPE \
        --backup-location=BACKUP_LOCATION
    

    更改下列內容:

    • SERVICE:Dataproc Metastore 服務的名稱。
    • PROJECT_ID:Dataproc Metastore 服務所在 Google Cloud專案的 ID。
    • LOCATION:Dataproc Metastore 服務所在的 Google Cloud 區域。
    • BACKUP:選用:您要從中還原的備份檔案 ID。這個值可以是備份 ID、完整限定網址,或以下格式的相對名稱:projects/{project_id}/locations/{location_id}/services/{service_id}/backups/{backup_id}
    • RESTORE_TYPE:要執行的還原作業類型。可接受的值包括 metadata-onlyfull。預設值為 metadata-only
    • BACKUP_LOCATION:選用:排定備份的 Cloud Storage 位置。例如:gs://my-bucket/path/to/location
  2. 確認還原作業是否成功。

    還原作業完成後,無論還原作業是否成功,Dataproc Metastore 都會自動返回有效狀態

REST

請按照 API 操作說明,使用 API Explorer 將中繼資料還原至服務

還原作業完成後,無論還原作業是否成功,Dataproc Metastore 都會自動返回有效狀態

查看還原記錄

如要在 Google Cloud 控制台中查看 Dataproc Metastore 服務的還原記錄,請完成下列步驟:

  1. 在 Google Cloud 控制台中,開啟「Dataproc Metastore」頁面。
  2. 在導覽列中,按一下「備份/還原」

    還原記錄會顯示在「還原」下方的表格中。

    歷史記錄最多會顯示您完成的 25 次最新還原作業。

    刪除 Dataproc Metastore 服務時,也會一併刪除所有相關的還原記錄。

排解常見問題

後續步驟