Managed Service for Apache Spark 的選用 Presto 元件

Presto 選用元件可讓您直接在 Managed Service for Apache Spark 叢集,對多個資料來源執行互動式分散式 SQL 查詢。Presto (Trino) 可處理外部儲存系統的分析工作負載,不需遷移資料。

安裝元件

請在建立 Managed Service for Apache Spark 叢集時安裝元件。若要新增元件,則需使用以 Managed Service for Apache Spark 1.3 以上版本所建立的叢集。

請參閱「支援的 Managed Service for Apache Spark 版本」,瞭解每個 Managed Service for Apache Spark 映像檔版本中包含的元件版本。

Google Cloud 控制台

  1. 在 Google Cloud 控制台,開啟「Create cluster」(建立叢集) 頁面。
  2. 按一下「其他設定」展開該部分。
  3. 編輯「Optional components」(選用元件)。
  4. 在開啟的面板中,勾選「Presto」Presto核取方塊。

gcloud CLI 指令

如要建立包含 Presto 元件的 Managed Service for Apache Spark 叢集,請使用 gcloud dataproc clusters create cluster-name 指令並加上 --optional-components 旗標。

gcloud dataproc clusters create cluster-name \
    --optional-components=PRESTO \
    --region=region \
    --enable-component-gateway \
    ... other flags

設定屬性

在 gcloud dataproc clusters create 指令中新增 --properties 旗標,即可設定 presto、presto-jvm 和 presto-catalog config 屬性。

  • 應用程式屬性:使用帶有 presto: 前置字元的叢集屬性,設定 Presto 應用程式屬性,例如 --properties="presto:join-distribution-type=AUTOMATIC"。
  • JVM 設定屬性:使用具有 presto-jvm: 前置字元的叢集屬性,為 Presto 協調器和 worker Java 程序設定 JVM 屬性,例如 --properties="presto-jvm:XX:+HeapDumpOnOutOfMemoryError"。
  • 建立新目錄並新增目錄資源:使用 presto-catalog:catalog-name.property-name 設定 Presto 目錄。

    範例:下列「properties」旗標可與「gcloud dataproc clusters create」指令搭配使用,建立具有「prodhive」Hive 目錄的 Presto 叢集。系統會在 /usr/lib/presto/etc/catalog/ 下建立 prodhive.properties 檔案,以啟用 prodhive 目錄。

    --properties="presto-catalog:prodhive.connector.name=hive-hadoop2,presto-catalog:prodhive.hive.metastore.uri=thrift://localhost:9083

REST API

您可以透過 Dataproc API,使用 SoftwareConfig.Component 做為 clusters.create 要求的一部分,指定 Presto 元件。

存取及查詢 Presto

根據預設,Presto 伺服器和網頁版 UI 位於叢集第一個主要節點的通訊埠 8060 上 (若 Kerberos 已啟用,則為通訊埠 7778)。

根據預設,Managed Service for Apache Spark 上的 Presto 會設定為與 Hive、BigQuery、Memory、TPCH 和 TPCDS 連接器搭配使用。

使用 Presto 元件建立叢集後,即可執行查詢: