本頁面說明如何為 Dataproc Metastore 建立中繼資料同盟服務。透過同盟服務,您可以從單一 gRPC 端點存取多個來源中儲存的中繼資料。
如要進一步瞭解同盟的運作方式和限制,請參閱「關於中繼資料同盟」。
事前準備
- 啟用 Dataproc Metastore。
- 建立使用 gRPC 端點的 Dataproc Metastore 服務。
- 選用:如果您使用 BigQuery 來源進行同盟,請完成下列步驟:
- 在包含 BigQuery 來源的專案中啟用 BigQuery API。
- 啟用 Resource Manager API。
- 選用:如果您使用 Dataplex Universal Catalog Lake 做為同盟 (搶先版) 的來源,請完成下列步驟:
- 在包含 Dataplex Universal Catalog Lake 做為來源的專案中,啟用 Dataplex Universal Catalog API。
必要的角色
如要取得建立同盟服務及附加 Dataproc 叢集所需的權限,請遵循最低權限原則,要求管理員授予您下列 IAM 角色:
-
如要存取同盟服務:
使用者帳戶或服務帳戶的同盟存取者 (
roles/metastore.federationAccessor
) -
如要授予所有 Dataproc Metastore 資源的完整控制權:
在使用者帳戶或服務帳戶上
指派 Dataproc Metastore 編輯者
roles/metastore.editor
-
如要在設定了同盟服務的 Dataproc Metastore 上完成中繼資料作業:
中繼存放區擁有者 (
metastore.metadataEditor
) 使用者帳戶或服務帳戶 -
如要建立 Dataproc 叢集:
Dataproc 工作站 (
roles/dataproc.worker
) 在 Dataproc VM 服務帳戶上 - (選用) 如要存取 BigQuery 資料集: 在使用者帳戶或服務帳戶中,使用適用於您用途的適當 BigQuery 預先定義角色
- (選用) 如要存取 Dataplex Universal Catalog Lakes (預覽版): 在使用者帳戶或服務帳戶中,使用適用於您用途的適當 Dataplex Universal Catalog 預先定義角色
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這些預先定義的角色包含建立同盟服務和附加 Dataproc 叢集所需的權限,並遵循最低權限原則。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要建立同盟服務並附加 Dataproc 叢集,請遵循最低權限原則,並具備下列權限:
-
如要建立 Dataproc Metastore,請在使用者帳戶或服務帳戶上執行下列操作:
metastore.services.create
-
如要列出、取得、建立、更新及刪除同盟服務:
metastore.federations.create, metastore.federations.update, metastore.federations.delete, metastore.federations.get metastore.federations.list
使用者帳戶或服務帳戶 -
如要在 Dataproc Metastore 上完成中繼資料作業:
metastore.services.get, metastore.services.use, metastore.databases.create, metastore.databases.update, metastore.databases.deletemetastore.databases.get,metastore.databases.list, metastore.databases.getIamPolicy, metastore.tables.create, metastore.tables.update, metastore.tables.delete, metastore.tables.get, metastore.tables.list, metastore.tables.getIamPolicy
在使用者帳戶或服務帳戶上 -
(選用) 如要將多區域服務新增至同盟:
metastore.services.get
在 Dataproc Metastore 帳戶上 -
(選用) 如要存取 BigQuery 資料集:
For more information, see BigQuery permissions
在使用者帳戶或服務帳戶上 -
(選用) 如要存取 Dataplex Universal Catalog Lakes (預覽版):
For more information, see Dataplex Universal Catalog permissions
在使用者帳戶或服務帳戶中
建立同盟服務
下列操作說明會介紹如何建立同盟服務,並將其附加至來源。完成這些步驟後,即可將同盟服務附加至 Dataproc 叢集。
如要進一步瞭解同盟來源及其限制,請參閱中繼資料來源。
控制台
在 Google Cloud 控制台中,開啟「Dataproc Metastore」頁面:
在 Dataproc 導覽選單中,按一下「Federation」(同盟)。
「Federated」(同盟) metastore 服務頁面隨即開啟。
在「Federated」中繼存放區選單列中,按一下「Create」。
「建立同盟服務」頁面隨即開啟。
在「Federation name」(聯盟名稱) 欄位中,輸入服務的專屬名稱。
詳情請參閱資源命名慣例。
選取「資料位置」。
請務必在 Dataproc Metastore 來源的相同區域中建立同盟服務。
選取 Hive 版本。
如要為同盟服務新增來源,請按一下「新增來源」。
你可以新增一或多個來源。您在這個清單中新增的第一個來源,會自動設為主要中繼資料存放區。建立後仍可更新來源排序。
在「來源類型」部分,選取您的同盟來源。
您可以選擇 Dataproc Metastore 執行個體、包含一或多個 BigQuery 資料集的專案,或是 Dataplex Universal Catalog 湖泊 (預先發布版)。
在「來源」欄位中輸入下列資訊:
Dataproc Metastore 服務。
在「Selected project」(所選專案) 欄位中,按一下「Browse」(瀏覽),然後選取包含要做為來源的 Dataproc Metastore 的專案。
請確認 Dataproc Metastore 來源使用的 Hive 版本與同盟服務相容。主要中繼儲存庫使用的 Hive 版本必須大於或等於同盟服務。
在「Metastore service」(中繼資料儲存庫服務) 下拉式選單中,選取要做為來源的 Dataproc Metastore。
(選用) 選取「顯示我的區域以外的 Metastore 服務」核取方塊。這份清單列出其他區域 (包括多重區域) 的 Dataproc Metastore 服務。
如要在多區域 Dataproc Metastore 服務上啟用同盟,請從這個清單中選取多區域 Dataproc Metastore 服務。
適用於 BigQuery。 在「所選專案」欄位中,按一下「瀏覽」,然後選取包含 BigQuery 資料集的專案 ID。
Dataplex Universal Catalog (預先發布版)。在「Selected project」(所選專案) 欄位中,按一下「Browse」(瀏覽),然後選取包含 Dataplex Universal Catalog Lake 的專案 ID。
按一下 [完成]。
如要建立並啟動服務,請按一下「Submit」(提交)。
現在您可以將同盟服務附加至 Dataproc 叢集。
gcloud CLI
如要使用 Dataproc Metastore 建立聯盟,請執行下列指令。
gcloud metastore federations create FEDERATION \ --location LOCATION \ --backends RANK=BACKEND_METASTORE \ --hive-metastore-version HIVE_VERSION
更改下列內容:
FEDERATION
:Dataproc Metastore 聯盟服務的名稱。LOCATION
:要在其中建立聯盟的 Google Cloud 區域。RANK
:每個後端中繼商店的排名編號,用於解決資料庫名稱衝突。同盟服務會先查詢排名較低的號碼。舉例來說,系統會先查詢等級為1
的後端中繼存放區,再查詢等級為2
的中繼存放區。這個值必須是整數。例如:--backends 1=first_backend_metastore, 2=second_backend_metastore
。BACKEND_METASTORE
:每個後端中繼資料存放區的相對資源,格式如下:METASTORE_TYPE:METASTORE_NAME
。如果是 Dataproc Metastore 服務,請使用dpms:SERVICE_ID
。SERVICE_ID
位於以下位置:projects/<project>/locations/<location>/services/<service-id>
。HIVE_VERSION
:Hive Metastore 版本 (3.1.2 或 2.3.6)。
更新同盟服務
下列操作說明將引導您更新同盟服務。您可以完成下列工作:
- 將來源新增至聯盟服務。
- 從同盟服務中移除來源。
- 變更聯盟服務中來源的來源順序。
永久刪除同盟服務。刪除服務後,系統會釋出所有資源。
控制台
https://cloud.google.com/dataproc-metastore/docs/create-federation
在 Google Cloud 控制台中,開啟「Dataproc Metastore」頁面:
在 Dataproc 導覽選單中,按一下「Federation」(同盟)。
「Federated」(同盟) metastore 服務頁面隨即開啟。
在「Federated」中繼存放區服務頁面,按一下要更新的服務名稱。
「服務詳細資料」頁面隨即開啟。
按一下選單列中的「編輯」。
「編輯服務」頁面隨即開啟。
選擇要更新的值。
如要更新服務,請按一下「提交」。
gcloud CLI
如要使用 Dataproc Metastore 更新同盟,請執行下列指令。
gcloud metastore federations update FEDERATATON \ --location=LOCATION \ --backends RANK1=BACKEND_METASTORE1,RANK2=BACKEND_METASTORE2
FEDERATION
:Dataproc Metastore 聯盟服務的名稱。LOCATION
:建立聯盟的 Google Cloud 區域。RANK
:每個後端中繼商店的排名編號,用於解決資料庫名稱衝突。同盟服務會先查詢排名較低的號碼。舉例來說,系統會先查詢等級為1
的後端中繼存放區,再查詢等級為2
的中繼存放區。這個值必須是整數。例如:--backends 2=first_backend_metastore, 2=second_backend_metastore
。BACKEND_METASTORE
:每個後端中繼資料存放區的相對資源,格式如下:METASTORE_TYPE:METASTORE_NAME
。如果是 Dataproc Metastore 服務,請使用dpms:SERVICE_ID
。SERVICE_ID
位於以下位置:projects/<project>/locations/<location>/services/<service-id>
。HIVE_VERSION
:Hive Metastore 版本 (3.1.2 或 2.3.6)。
將 Dataproc 叢集附加至同盟服務
以下操作說明將示範如何建立 Dataproc 叢集,並將同盟服務端點附加為其 Metastore。
開始按照這些操作說明進行之前,請先完成「事前準備」一節中列出的所有步驟,並建立同盟服務。
gcloud CLI
如要建立 Dataproc 叢集並附加同盟端點,請執行下列 gcloud Dataproc clusters create
指令。
gcloud dataproc clusters create CLUSTER_NAME \ --region=LOCATION \ --project=PROJECT_ID \ --scopes=https://www.googleapis.com/auth/cloud-platform \ --image-version=IMAGE_VERSION \ --service-account=SERVICE_ACCOUNT \ --optional-components=DOCKER \ --initialization-actions=gs://metastore-init-actions/metastore-grpc-proxy/metastore-grpc-proxy.sh \ --metadata="proxy-uri=FEDERATION_URI,hive-version=FEDERATION_VERSION" \ --properties="hive:hive.metastore.uris=thrift://localhost:9083,hive:hive.metastore.warehouse.dir=WAREHOUSE_DIR"
更改下列內容:
CLUSTER_NAME
:新 Dataproc 叢集的名稱。PROJECT_ID
:您要在其中建立 Dataproc 叢集的專案 ID。 Google CloudLOCATION
:Dataproc 叢集所在的區域。IMAGE_VERSION
:要使用的 Dataproc 映像檔版本。請確認您在此指令中使用的 Dataproc 映像檔,與用於聯盟服務的 Hive 版本相容。詳情請參閱 Dataproc 映像檔版本清單。
SERVICE_ACCOUNT
選用:用於建立 Dataproc 叢集的服務帳戶。如未指定,叢集會使用預設的 Compute Engine 服務帳戶。FEDERATION_URI
:您的聯盟服務端點 URI。FEDERATION_VERSION
:您的聯盟服務使用的 Hive 版本。WAREHOUSE_DIR
:主要 Dataproc Metastore 的倉儲目錄。