根據預設,Dataproc Metastore 會加密靜態儲存的客戶內容。Dataproc Metastore 會處理加密作業,您不必採取任何其他動作。這個選項稱為「Google 預設加密」。
如果您想控制加密金鑰,可以在 Cloud KMS 中使用客戶自行管理的加密金鑰 (CMEK),並搭配使用 CMEK 整合服務,包括 Dataproc Metastore。使用 Cloud KMS 金鑰可讓您控制金鑰的保護等級、位置、輪替時間表、使用權限和存取權,以及加密範圍。使用 Cloud KMS 還可讓您查看稽核記錄,並控管金鑰生命週期。您可以在 Cloud KMS 中控制及管理用來保護資料的對稱金鑰加密金鑰 (KEK),而非由 Google 擁有及管理這些金鑰。
使用 CMEK 設定資源後,存取 Dataproc Metastore 資源的體驗就會類似於使用 Google 預設加密功能。如要進一步瞭解加密選項,請參閱「客戶管理的加密金鑰 (CMEK)」。
事前準備
注意事項
使用 Dataproc Metastore 時,請考量下列 CMEK 相關事項。
單一區域和多區域 Dataproc Metastore 服務都支援 CMEK (預先發布版)。
Cloud Monitoring 資料庫不支援 CMEK 加密。Google Cloud 會使用 Google 加密金鑰來保護 Dataproc Metastore 服務的名稱和服務設定。
如果您希望 Dataproc Metastore 服務在 VPC Service Controls 範圍內執行,必須將 Cloud Key Management Service (Cloud KMS) API 新增至範圍。
使用 Cloud External Key Manager 金鑰時,Google 無法控管外部代管金鑰的供應情形。如果在 Dataproc Metastore 服務建立期間無法使用金鑰,服務建立作業就會失敗。建立 Dataproc Metastore 服務後,如果金鑰無法使用,服務就會無法使用,直到金鑰再次可用為止。如要進一步瞭解使用外部金鑰時的考量,請參閱「Cloud EKM 注意事項」。
限制
使用 Dataproc Metastore 時,請考量下列 CMEK 限制。
您無法在現有服務上啟用 CMEK。
您無法輪替啟用 CMEK 的服務所使用的 CMEK。
您無法使用 CMEK 加密傳輸中的使用者資料,例如使用者查詢和回應。
為 Dataproc Metastore 設定 CMEK
如果您還沒有 Cloud KMS 金鑰,可以為 Dataproc Metastore 服務建立金鑰。否則,您可以略過這個步驟並使用現有的金鑰。
選用:建立新的 Cloud KMS 金鑰
如要建立 Cloud KMS 金鑰,請先建立金鑰環,然後建立金鑰並儲存在金鑰環中。
建立金鑰環
如要建立鑰匙圈,請執行下列 gcloud kms keyrings create
指令。
gcloud kms keyrings create KEY_RING \ --project=PROJECT_ID \ --location=LOCATION
更改下列內容:
KEY_RING
:金鑰環的名稱。PROJECT_ID
:您要建立鑰匙圈的 Google Cloud 專案 ID。LOCATION
:您要在其中建立金鑰環的地區。
如何建立金鑰
如要建立儲存在金鑰環中的金鑰,請執行下列 gcloud kms keys create
指令。
gcloud kms keys create KEY_NAME \ --project=PROJECT_ID \ --location=LOCATION \ --keyring=KEY_RING \ --purpose=encryption
更改下列內容:
KEY_NAME
:鍵的名稱。KEY_RING
:您在上一個步驟中建立的金鑰環名稱。
授予 Cloud KMS 金鑰權限
使用下列指令,為 Dataproc Metastore 授予 Cloud KMS 金鑰權限:
將權限授予 Dataproc Metastore 服務代理服務帳戶:
如果您要為多區域 Dataproc Metastore 服務設定 CMEK,則必須為 每個金鑰授予 Dataproc Metastore 和 Cloud Storage 服務帳戶所需的 Cloud KMS 權限。
gcloud kms keys add-iam-policy-binding KEY_NAME \ --location LOCATION \ --keyring KEY_RING \ --member=serviceAccount:$(gcloud beta services identity create \ --service=metastore.googleapis.com 2>&1 | awk '{print $4}') \ --role=roles/cloudkms.cryptoKeyEncrypterDecrypter
將權限授予 Cloud Storage 服務帳戶:
gcloud storage service-agent --authorize-cmek projects/KEY_PROJECT/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME
使用 CMEK 金鑰建立單一區域服務
請按照下列步驟,為單一區域的 Dataproc Metastore 服務設定 CMEK 加密機制。
控制台
在 Google Cloud 控制台中,前往 Dataproc Metastore 頁面:
按一下「Dataproc Metastore」頁面頂端的「建立」。
「Create service」(建立服務) 頁面隨即開啟。
視需要設定服務。
在「加密」下方,按一下「客戶管理的加密金鑰 (CMEK)」。
選取客戶管理的金鑰。
按一下「提交」。
驗證服務的加密設定:
在 Google Cloud 控制台中,前往 Dataproc Metastore 頁面:
在「Dataproc Metastore」頁面中,按一下要查看的服務名稱。
「服務詳細資料」頁面隨即開啟。
在「Configuration」分頁下,確認詳細資料顯示已啟用 CMEK。
gcloud
如要建立使用 CMEK 加密的單一區域服務,請執行Google Cloud
gcloud metastore services create
指令:gcloud metastore services create SERVICE \ --encryption-kms-key=KMS_KEY
更改下列內容:
SERVICE
:新服務的名稱。KMS_KEY
:金鑰資源 ID。
使用 CMEK 金鑰建立多區域服務
對於多區域 Dataproc Metastore CMEK 服務,您需要提供多個加密金鑰。這包括多地區 Dataproc Metastore 服務的每個構成區域都有一個鍵,分別為 Spanner 見證區域和大洲各一個鍵。
如要取得多地區服務及其所配置的地區相關資訊,請執行下列指令。
gcloud metastore locations describe LOCATION
- 將 LOCATION 替換為您建立 Dataproc Metastore 服務的多區域。
如何使用 CMEK 金鑰建立多區域服務
請按照下列步驟,為多區域 Dataproc Metastore 服務設定 CMEK 加密機制。
控制台
在 Google Cloud 控制台中,前往 Dataproc Metastore 頁面:
按一下「Dataproc Metastore」頁面頂端的「建立」。
「Create service」(建立服務) 頁面隨即開啟。
選取「Dataproc Metastore 2」。
在「價格和容量」專區中,選取「Enterprise Plus - 雙區域」。
在「Endpoint protocol」 中,選取適當的端點。
在「Encryption」下方,選取「Cloud KMS key」。
選取要用於各區域的鍵,例如 Spanner 見證區域和洲別。
視需要設定其餘服務選項。
按一下「提交」。
驗證服務的加密設定:
在 Google Cloud 控制台中,前往 Dataproc Metastore 頁面:
在「Dataproc Metastore」頁面中,按一下要查看的服務名稱。
系統會開啟「服務詳細資料」。
在「Configuration」分頁下方,確認已啟用 CMEK。
gcloud
- 如要建立使用 CMEK 加密的多區域服務,請執行
gcloud beta metastore services create
指令:
gcloud beta metastore services create SERVICE \ --location=LOCATION \ --instance-size=INSTANCE_SIZE \ --encryption-kms-keys=KMS_KEY1,KMS_KEY2,KMS_KEY_WITNESS,KMS_KEY_CONTINENT
更改下列內容:
SERVICE
:新 Dataproc Metastore 服務的名稱。LOCATION
:您要建立 Dataproc Metastore 服務的 Google Cloud 多區域。您也可以設定預設位置。INSTANCE_SIZE
:多區域 Dataproc Metastore 服務的執行個體大小。例如小、中或大。KMS_KEY1, KMS_KEY2, KMS_KEY_WITNESS, KMS_KEY_CONTINENT
:每個必要索引鍵的索引鍵資源 ID,包括一個位於大陸的索引鍵和一個位於 Spanner 見證區的索引鍵。在專案中,金鑰名稱會以以下格式列出:projects/KEY_PROJECT/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME
。
將資料匯入及匯出支援 CMEK 的服務
如果您希望在匯入期間,資料仍能以客戶自行管理的金鑰加密,請務必先在 Cloud Storage 值區設定 CMEK,再從該值區匯入資料。
您可以從未受 CMEK 保護的 Cloud Storage 值區匯入資料。匯入後,Dataproc Metastore 中儲存的資料會根據目的地服務的 CMEK 設定受到保護。
匯出時,系統會根據目的地儲存值區的 CMEK 設定保護匯出的資料庫傾印。