本頁面提供詳細指引,說明如何為 Dataproc Metastore 執行個體設定網路存取權。正確設定網路是 Managed Service for Apache Spark 叢集和 Managed Service for Apache Spark 工作負載與代管 Dataproc Metastore 服務安全私下通訊的必要條件。
如需網路概念的更一般總覽,請參閱「網路總覽」。
重要網路概念
Dataproc Metastore 執行個體通常位於 Google 管理的服務供應商網路中,並使用私人連線與虛擬私有雲 (VPC) 網路通訊。如要順利完成設定,請務必瞭解下列概念:
- Shared VPC:如果您的 Apache Spark 代管服務叢集或 Apache Spark 代管服務工作負載位於服務專案中,且該專案使用主專案的 Shared VPC 網路,請確認主專案中已完成適當的網路設定。詳情請參閱「Shared VPC 總覽」。
- Private Google Access:Dataproc Metastore 執行個體通常會透過 Private Google Access,與虛擬私有雲網路進行私人通訊。這樣一來,虛擬私有雲中的虛擬機器 (VM) 執行個體就能使用內部 IP 位址連線至 Google API 和服務。詳情請參閱Private Google Access。
- VPC 網路對等互連:這項機制可在兩個 VPC 網路之間建立私人 IP 連線,讓一個網路中的資源使用內部 IP 位址與另一個網路中的資源通訊。Dataproc Metastore 會在設定期間,與您的虛擬私有雲網路建立受管理虛擬私有雲網路對等互連連線。詳情請參閱「虛擬私有雲網路對等互連」。
- 防火牆規則:您必須設定適當的防火牆規則,才能允許 Managed Service for Apache Spark 工作負載與 Dataproc Metastore 執行個體之間的流量。
- Cloud DNS 解析:確認虛擬私有雲網路中的 DNS 解析設定正確,可將 Dataproc Metastore 端點 URI 解析為私人 IP 位址。
設定步驟
如要驗證 Dataproc Metastore 執行個體是否具備適當的網路存取權,請按照下列步驟操作:
1. 設定 Private Service Access
Dataproc Metastore 會使用 Private Service Access,在虛擬私有雲網路與 Google 管理的服務供應商網路之間建立私人連線,Dataproc Metastore 執行個體就位於該網路中。
- 驗證 Private Service Access 連線:
- 在 Google Cloud 控制台中,前往「虛擬私有雲網路」>「虛擬私有雲網路對等互連」。
- 確認名為
servicenetworking-googleapis-com的對等互連連線存在,且狀態為ACTIVE。 - 如果缺少這項連線或連線未啟用,請按照「設定 Private Service Access」一文的操作說明進行設定。包括為服務供應商網路分配 IP 位址範圍。
2. 設定防火牆規則
確認虛擬私有雲網路 (或適用的 Shared VPC 主專案) 中的防火牆規則允許必要流量。
- 從工作負載到 Metastore 的輸出規則:
- 確認輸出防火牆規則允許從 Managed Service for Apache Spark 叢集或 Managed Service for Apache Spark 工作負載,透過通訊埠
9083將輸出 TCP 流量傳送至 Dataproc Metastore 執行個體的 IP 位址範圍。這是 Hive Metastore 的預設通訊埠。 - 如果使用 Private Service Access,這類流量會以私密方式轉送。
- 確認輸出防火牆規則允許從 Managed Service for Apache Spark 叢集或 Managed Service for Apache Spark 工作負載,透過通訊埠
- 輸入規則 (用戶端到 Metastore 較不常見):
- 一般來說,您不需要在虛擬私有雲上設定連入規則,允許流量從 Dataproc Metastore 執行個體傳送至工作負載,因為通訊通常是從工作負載發起。不過,請確認沒有過於嚴格的輸入規則,以免不慎封鎖必要的回應。
3. 驗證 DNS 解析
Apache Spark 工作負載的代管服務需要將 Dataproc Metastore 端點 URI 解析為私人 IP 位址。
- DNS 對等互連或私人區域:如果您使用自訂 DNS 伺服器或私人 Cloud DNS 區域,請確認 Dataproc Metastore 端點 (例如
your-metastore-endpoint.us-central1.dataproc.cloud.google.com) 的 DNS 查詢是否正確轉送或解析至 Private Service Access 使用的私人 IP 範圍。 - 測試 DNS 解析:從與 Managed Service for Apache Spark 工作負載位於相同子網路的 VM,使用
nslookup或dig驗證 Dataproc Metastore 端點是否解析為私人 IP 位址。
排解網路連線問題
設定網路存取權後,如果遇到連線問題,請嘗試下列疑難排解步驟:
- 檢查 Dataproc Metastore 狀態:確認 Dataproc Metastore 執行個體在Google Cloud 控制台中處於
HEALTHY狀態。 - 檢查 Cloud Logging:檢查 Dataproc Metastore 執行個體和相關的 Managed Service for Apache Spark 工作負載的 Cloud Logging,找出與網路相關的錯誤訊息或連線逾時。
- 使用 Network Intelligence Center Connectivity Tests:使用 Google Cloud的 Connectivity Tests,診斷從 Managed Service for Apache Spark 工作負載的 VM 到 Dataproc Metastore 端點的網路路徑。
- 請參閱一般疑難排解:如需更詳細的網路診斷資訊,請參閱:
後續步驟
- 進一步瞭解 Dataproc Metastore。
- 查看 Managed Service for Apache Spark 網路選項。
- 瞭解 VPC 網路對接。