セルフマネージド MySQL メタストアを Dataproc Metastore に移行する

このページでは、MySQL ダンプファイルを作成し、既存の 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. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  3. Google Cloud プロジェクトで課金が有効になっていることを確認します

  4. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  5. Google Cloud プロジェクトで課金が有効になっていることを確認します

  6. Dataproc Metastore API を有効にします。

    API を有効にする

必要なロール

Dataproc Metastore の作成と MYSQL メタストアのインポートに必要な権限を取得するには、管理者に次の IAM のロールを付与するよう依頼してください。

ロールの付与の詳細については、アクセスの管理をご覧ください。

これらの事前定義ロールには、Dataproc Metastore の作成と MYSQL メタストアのインポートに必要な権限が含まれています。必要な権限を正確に確認するには、[必要な権限] セクションを開いてください。

必要な権限

Dataproc Metastore を作成し、MYSQL メタストアをインポートするには、次の権限が必要です。

  • サービスを作成するには: プロジェクトに対する metastore.services.create
  • メタデータをインポートするには: プロジェクトに対する metastore.imports.create
  • インポートに Cloud Storage オブジェクト(SQL ダンプファイル)を使用するには:
    • Dataproc Metastore サービス エージェントに対する storage.objects.get。例: service-CUSTOMER_PROJECT_NUMBER@gcp-sa-metastore.iam.gserviceaccount.com
    • ユーザー アカウントに対する storage.objects.get

カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。

Dataproc Metastore の特定のロールと権限については、IAM による Dataproc のアクセス管理をご覧ください。

Dataproc Metastore サービスを作成する

次の手順では、SQL ダンプファイルの移行先となる Dataproc Metastore サービスを作成する方法を説明します。

コンソール

  1. Google Cloud コンソールで [サービスの作成] ページを開きます。

    [サービスの作成] に移動

    [Create service] ページ。
    Dataproc Metastore の [サービスの作成] ページ
  2. [サービス名] フィールドに「example-service」と入力します。

  3. [Data location] を選択します。 リージョンの選択については、Cloud のロケーションをご覧ください。

  4. その他のサービス構成オプションには、指定されたデフォルト値を使用します。

  5. サービスを作成して開始するには、[送信] ボタンをクリックします。

サービスの一覧に新しいサービスが表示されます。

gcloud

次のgcloud metastore services createコマンドを実行してサービスを作成します。

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

LOCATION は、サービスを作成する予定の Compute Engine のリージョンに置き換えます。そのリージョンで Dataproc Metastore が利用可能であることを確認します。

REST

API Explorer を使用し、API の手順に従ってサービスを作成します。

移行の準備を行う

MySQL ダンプファイルを作成して Cloud Storage バケットに配置することで、Hive メタストア データベースに保存されているインポート用メタデータを準備する必要があります。

移行の準備手順については、インポート前にインポート ファイルを準備するをご覧ください。

メタデータをインポートする

これでダンプの準備ができたので、ダンプを Dataproc Metastore サービスにインポートします。

example-service サービスにメタデータをインポートする手順については、Dataproc Metastore へのファイルのインポートをご覧ください。

Dataproc クラスタを作成して接続する

Dataproc Metastore example-service サービスにメタデータをインポートしたら、そのサービスを Hive メタストアとして使用する Dataproc クラスタを作成してアタッチします。

クリーンアップ

このページで使用したリソースについて、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 サービスを削除します。

    Console

    1. Google Cloud コンソールで、[Dataproc Metastore] ページを開きます。

      Google Cloud コンソールで Dataproc Metastore を開く

    2. サービス名の左側にあるチェックボックスをオンにして、example-service を選択します。

    3. [Dataproc Metastore] ページの上部にある [削除] をクリックして、そのサービスを削除します。

    4. ダイアログで [Delete] をクリックして、削除を確定します。

    サービスがサービスの一覧に表示されなくなります。

    gcloud

    次の gcloud metastore services delete コマンドを実行して、サービスを削除します。

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

    LOCATION は、そのサービスを作成した Compute Engine のリージョンに置き換えます。

    REST

    API Explorer を使用し、API の手順に従ってサービスを削除します。

    削除はすべてすぐに正常終了します。

  2. Dataproc Metastore サービスの Cloud Storage バケットを削除します

次のステップ